]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/index/detail/translator.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / index / detail / translator.hpp
1 // Boost.Geometry Index
2 //
3 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
4 //
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
8 //
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)
12
13 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
14 #define BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
15
16 #include <type_traits>
17
18 namespace boost { namespace geometry { namespace index {
19
20 namespace detail {
21
22 template <typename Strategy>
23 struct translator_equals
24 {
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)
29 {
30 return equal_to(v1, v2, strategy);
31 }
32 };
33
34 template <>
35 struct translator_equals<default_strategy>
36 {
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&)
41 {
42 return equal_to(v1, v2);
43 }
44 };
45
46 template <typename IndexableGetter, typename EqualTo>
47 struct translator
48 : public IndexableGetter
49 , public EqualTo
50 {
51 typedef typename IndexableGetter::result_type result_type;
52
53 translator(IndexableGetter const& i, EqualTo const& e)
54 : IndexableGetter(i), EqualTo(e)
55 {}
56
57 template <typename Value>
58 result_type operator()(Value const& value) const
59 {
60 return IndexableGetter::operator()(value);
61 }
62
63 template <typename Value, typename Strategy>
64 bool equals(Value const& v1, Value const& v2, Strategy const& strategy) const
65 {
66 return translator_equals
67 <
68 Strategy
69 >::apply(static_cast<EqualTo const&>(*this), v1, v2, strategy);
70 }
71 };
72
73 template <typename IndexableGetter>
74 struct result_type
75 {
76 typedef typename IndexableGetter::result_type type;
77 };
78
79 template <typename IndexableGetter>
80 struct indexable_type
81 {
82 typedef typename std::remove_const<
83 typename std::remove_reference<
84 typename result_type<IndexableGetter>::type
85 >::type
86 >::type type;
87 };
88
89 } // namespace detail
90
91 }}} // namespace boost::geometry::index
92
93 #endif // BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP