translator.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Boost.Geometry Index
  2. //
  3. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  4. //
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
  9. #define BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP
  10. namespace boost { namespace geometry { namespace index {
  11. namespace detail {
  12. template <typename IndexableGetter, typename EqualTo>
  13. struct translator
  14. : public IndexableGetter
  15. , public EqualTo
  16. {
  17. typedef typename IndexableGetter::result_type result_type;
  18. translator(IndexableGetter const& i, EqualTo const& e)
  19. : IndexableGetter(i), EqualTo(e)
  20. {}
  21. template <typename Value>
  22. result_type operator()(Value const& value) const
  23. {
  24. return IndexableGetter::operator()(value);
  25. }
  26. template <typename Value>
  27. bool equals(Value const& v1, Value const& v2) const
  28. {
  29. return EqualTo::operator()(v1, v2);
  30. }
  31. };
  32. template <typename IndexableGetter>
  33. struct result_type
  34. {
  35. typedef typename IndexableGetter::result_type type;
  36. };
  37. template <typename IndexableGetter>
  38. struct indexable_type
  39. {
  40. typedef typename boost::remove_const<
  41. typename boost::remove_reference<
  42. typename result_type<IndexableGetter>::type
  43. >::type
  44. >::type type;
  45. };
  46. } // namespace detail
  47. }}} // namespace boost::geometry::index
  48. #endif // BOOST_GEOMETRY_INDEX_DETAIL_TRANSLATOR_HPP