comparable.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Boost.Geometry
  2. // Copyright (c) 2021, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_HPP
  8. #include <boost/geometry/core/cs.hpp>
  9. #include <boost/geometry/core/static_assert.hpp>
  10. #include <boost/geometry/strategies/distance.hpp>
  11. namespace boost { namespace geometry
  12. {
  13. namespace strategies { namespace distance
  14. {
  15. #ifndef DOXYGEN_NO_DETAIL
  16. namespace detail
  17. {
  18. template <typename Strategies>
  19. struct comparable
  20. : public Strategies
  21. {
  22. comparable() = default;
  23. explicit comparable(Strategies const& strategies)
  24. : Strategies(strategies)
  25. {}
  26. template <typename Geometry1, typename Geometry2>
  27. auto distance(Geometry1 const& g1, Geometry2 const& g2) const
  28. {
  29. return strategy::distance::services::get_comparable
  30. <
  31. decltype(Strategies::distance(g1, g2))
  32. >::apply(Strategies::distance(g1, g2));
  33. }
  34. };
  35. template <typename Strategies>
  36. inline comparable<Strategies> make_comparable(Strategies const& strategies)
  37. {
  38. return comparable<Strategies>(strategies);
  39. }
  40. } // namespace detail
  41. #endif // DOXYGEN_NO_DETAIL
  42. }} // namespace strategies::distance
  43. }} // namespace boost::geometry
  44. #endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_HPP