]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/index/detail/translator.hpp
bump version to 18.2.2-pve1
[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-2021.
6 // Modifications copyright (c) 2019-2021 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 #include <boost/geometry/strategies/default_strategy.hpp>
19
20 namespace boost { namespace geometry { namespace index {
21
22 namespace detail {
23
24 template <typename Strategy>
25 struct translator_equals
26 {
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)
31 {
32 return equal_to(v1, v2, strategy);
33 }
34 };
35
36 template <>
37 struct translator_equals<default_strategy>
38 {
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&)
43 {
44 return equal_to(v1, v2);
45 }
46 };
47
48 template <typename IndexableGetter, typename EqualTo>
49 struct translator
50 : public IndexableGetter
51 , public EqualTo
52 {
53 typedef typename IndexableGetter::result_type result_type;
54
55 translator(IndexableGetter const& i, EqualTo const& e)
56 : IndexableGetter(i), EqualTo(e)
57 {}
58
59 template <typename Value>
60 result_type operator()(Value const& value) const
61 {
62 return IndexableGetter::operator()(value);
63 }
64
65 template <typename Value, typename Strategy>
66 bool equals(Value const& v1, Value const& v2, Strategy const& strategy) const
67 {
68 return translator_equals
69 <
70 Strategy
71 >::apply(static_cast<EqualTo const&>(*this), v1, v2, strategy);
72 }
73 };
74
75 template <typename IndexableGetter>
76 struct result_type
77 {
78 typedef typename IndexableGetter::result_type type;
79 };
80
81 template <typename IndexableGetter>
82 struct indexable_type
83 {
84 typedef typename std::remove_const<
85 typename std::remove_reference<
86 typename result_type<IndexableGetter>::type
87 >::type
88 >::type type;
89 };
90
91 } // namespace detail
92
93 }}} // namespace boost::geometry::index
94
95 #endif // BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP