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