1 // Boost.Geometry Index
3 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
5 // This file was modified by Oracle on 2019-2020.
6 // Modifications copyright (c) 2019-2020 Oracle and/or its affiliates.
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9 // Use, modification and distribution is subject to the Boost Software License,
10 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
14 #define BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
16 #include <type_traits>
18 namespace boost { namespace geometry { namespace index {
22 template <typename Strategy>
23 struct translator_equals
25 template <typename EqualTo, typename Value>
26 static inline bool apply(EqualTo const& equal_to,
27 Value const& v1, Value const& v2,
28 Strategy const& strategy)
30 return equal_to(v1, v2, strategy);
35 struct translator_equals<default_strategy>
37 template <typename EqualTo, typename Value>
38 static inline bool apply(EqualTo const& equal_to,
39 Value const& v1, Value const& v2,
40 default_strategy const&)
42 return equal_to(v1, v2);
46 template <typename IndexableGetter, typename EqualTo>
48 : public IndexableGetter
51 typedef typename IndexableGetter::result_type result_type;
53 translator(IndexableGetter const& i, EqualTo const& e)
54 : IndexableGetter(i), EqualTo(e)
57 template <typename Value>
58 result_type operator()(Value const& value) const
60 return IndexableGetter::operator()(value);
63 template <typename Value, typename Strategy>
64 bool equals(Value const& v1, Value const& v2, Strategy const& strategy) const
66 return translator_equals
69 >::apply(static_cast<EqualTo const&>(*this), v1, v2, strategy);
73 template <typename IndexableGetter>
76 typedef typename IndexableGetter::result_type type;
79 template <typename IndexableGetter>
82 typedef typename std::remove_const<
83 typename std::remove_reference<
84 typename result_type<IndexableGetter>::type
91 }}} // namespace boost::geometry::index
93 #endif // BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP