translator.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
  13. #define BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
  14. namespace boost { namespace geometry { namespace index {
  15. namespace detail {
  16. template <typename Strategy>
  17. struct translator_equals
  18. {
  19. template <typename EqualTo, typename Value>
  20. static inline bool apply(EqualTo const& equal_to,
  21. Value const& v1, Value const& v2,
  22. Strategy const& strategy)
  23. {
  24. return equal_to(v1, v2, strategy);
  25. }
  26. };
  27. template <>
  28. struct translator_equals<default_strategy>
  29. {
  30. template <typename EqualTo, typename Value>
  31. static inline bool apply(EqualTo const& equal_to,
  32. Value const& v1, Value const& v2,
  33. default_strategy const&)
  34. {
  35. return equal_to(v1, v2);
  36. }
  37. };
  38. template <typename IndexableGetter, typename EqualTo>
  39. struct translator
  40. : public IndexableGetter
  41. , public EqualTo
  42. {
  43. typedef typename IndexableGetter::result_type result_type;
  44. translator(IndexableGetter const& i, EqualTo const& e)
  45. : IndexableGetter(i), EqualTo(e)
  46. {}
  47. template <typename Value>
  48. result_type operator()(Value const& value) const
  49. {
  50. return IndexableGetter::operator()(value);
  51. }
  52. template <typename Value, typename Strategy>
  53. bool equals(Value const& v1, Value const& v2, Strategy const& strategy) const
  54. {
  55. return translator_equals
  56. <
  57. Strategy
  58. >::apply(static_cast<EqualTo const&>(*this), v1, v2, strategy);
  59. }
  60. };
  61. template <typename IndexableGetter>
  62. struct result_type
  63. {
  64. typedef typename IndexableGetter::result_type type;
  65. };
  66. template <typename IndexableGetter>
  67. struct indexable_type
  68. {
  69. typedef typename boost::remove_const<
  70. typename boost::remove_reference<
  71. typename result_type<IndexableGetter>::type
  72. >::type
  73. >::type type;
  74. };
  75. } // namespace detail
  76. }}} // namespace boost::geometry::index
  77. #endif // BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP