1 // Boost.Geometry Index
3 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
5 // This file was modified by Oracle on 2019-2021.
6 // Modifications copyright (c) 2019-2021 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 #include <boost/geometry/strategies/default_strategy.hpp>
20 namespace boost { namespace geometry { namespace index {
24 template <typename Strategy>
25 struct translator_equals
27 template <typename EqualTo, typename Value>
28 static inline bool apply(EqualTo const& equal_to,
29 Value const& v1, Value const& v2,
30 Strategy const& strategy)
32 return equal_to(v1, v2, strategy);
37 struct translator_equals<default_strategy>
39 template <typename EqualTo, typename Value>
40 static inline bool apply(EqualTo const& equal_to,
41 Value const& v1, Value const& v2,
42 default_strategy const&)
44 return equal_to(v1, v2);
48 template <typename IndexableGetter, typename EqualTo>
50 : public IndexableGetter
53 typedef typename IndexableGetter::result_type result_type;
55 translator(IndexableGetter const& i, EqualTo const& e)
56 : IndexableGetter(i), EqualTo(e)
59 template <typename Value>
60 result_type operator()(Value const& value) const
62 return IndexableGetter::operator()(value);
65 template <typename Value, typename Strategy>
66 bool equals(Value const& v1, Value const& v2, Strategy const& strategy) const
68 return translator_equals
71 >::apply(static_cast<EqualTo const&>(*this), v1, v2, strategy);
75 template <typename IndexableGetter>
78 typedef typename IndexableGetter::result_type type;
81 template <typename IndexableGetter>
84 typedef typename std::remove_const<
85 typename std::remove_reference<
86 typename result_type<IndexableGetter>::type
93 }}} // namespace boost::geometry::index
95 #endif // BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP