Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:33

0001 // Boost.Geometry Index
0002 //
0003 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
0004 //
0005 // This file was modified by Oracle on 2019-2021.
0006 // Modifications copyright (c) 2019-2021 Oracle and/or its affiliates.
0007 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0008 //
0009 // Use, modification and distribution is subject to the Boost Software License,
0010 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
0014 #define BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
0015 
0016 #include <type_traits>
0017 
0018 #include <boost/geometry/strategies/default_strategy.hpp>
0019 
0020 namespace boost { namespace geometry { namespace index {
0021 
0022 namespace detail {
0023 
0024 template <typename Strategy>
0025 struct translator_equals
0026 {
0027     template <typename EqualTo, typename Value>
0028     static inline bool apply(EqualTo const& equal_to,
0029                              Value const& v1, Value const& v2,
0030                              Strategy const& strategy)
0031     {
0032         return equal_to(v1, v2, strategy);
0033     }
0034 };
0035 
0036 template <>
0037 struct translator_equals<default_strategy>
0038 {
0039     template <typename EqualTo, typename Value>
0040     static inline bool apply(EqualTo const& equal_to,
0041                              Value const& v1, Value const& v2,
0042                              default_strategy const&)
0043     {
0044         return equal_to(v1, v2);
0045     }
0046 };
0047 
0048 template <typename IndexableGetter, typename EqualTo>
0049 struct translator
0050     : public IndexableGetter
0051     , public EqualTo
0052 {
0053     typedef typename IndexableGetter::result_type result_type;
0054 
0055     translator(IndexableGetter const& i, EqualTo const& e)
0056         : IndexableGetter(i), EqualTo(e)
0057     {}
0058 
0059     template <typename Value>
0060     result_type operator()(Value const& value) const
0061     {
0062         return IndexableGetter::operator()(value);
0063     }
0064 
0065     template <typename Value, typename Strategy>
0066     bool equals(Value const& v1, Value const& v2, Strategy const& strategy) const
0067     {
0068         return translator_equals
0069                 <
0070                     Strategy
0071                 >::apply(static_cast<EqualTo const&>(*this), v1, v2, strategy);
0072     }
0073 };
0074 
0075 template <typename IndexableGetter>
0076 struct result_type
0077 {
0078     typedef typename IndexableGetter::result_type type;
0079 };
0080 
0081 template <typename IndexableGetter>
0082 struct indexable_type
0083 {
0084     typedef typename std::remove_const<
0085         typename std::remove_reference<
0086             typename result_type<IndexableGetter>::type
0087         >::type
0088     >::type type;
0089 };
0090 
0091 } // namespace detail
0092 
0093 }}} // namespace boost::geometry::index
0094 
0095 #endif // BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP