area_result.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Boost.Geometry
  2. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
  3. // Use, modification and distribution is subject to the Boost Software License,
  4. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_GEOMETRY_STRATEGIES_AREA_RESULT_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_AREA_RESULT_HPP
  8. #include <boost/geometry/core/coordinate_type.hpp>
  9. #include <boost/geometry/core/cs.hpp>
  10. #include <boost/geometry/strategies/area.hpp>
  11. #include <boost/geometry/strategies/default_strategy.hpp>
  12. #include <boost/geometry/util/select_most_precise.hpp>
  13. #include <boost/geometry/util/select_sequence_element.hpp>
  14. #include <boost/mpl/if.hpp>
  15. #include <boost/type_traits/is_same.hpp>
  16. #include <boost/variant/variant_fwd.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. /*!
  20. \brief Meta-function defining return type of area function
  21. \ingroup area
  22. \note The return-type is defined by Geometry and Strategy
  23. */
  24. template
  25. <
  26. typename Geometry,
  27. typename Strategy = default_strategy
  28. >
  29. struct area_result
  30. : Strategy::template result_type<Geometry>
  31. {};
  32. template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
  33. struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy>
  34. : geometry::area_result
  35. <
  36. typename geometry::util::select_sequence_element
  37. <
  38. typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
  39. >::type,
  40. Strategy
  41. >
  42. {};
  43. template <typename Geometry>
  44. struct area_result<Geometry, default_strategy>
  45. : geometry::area_result
  46. <
  47. Geometry,
  48. typename geometry::strategy::area::services::default_strategy
  49. <
  50. typename cs_tag<Geometry>::type
  51. >::type
  52. >
  53. {};
  54. #ifndef DOXYGEN_NO_DETAIL
  55. namespace detail { namespace area
  56. {
  57. template <typename Curr, typename Next>
  58. struct pred_more_precise_default_area_result
  59. {
  60. typedef typename geometry::area_result<Curr, default_strategy>::type curr_result_t;
  61. typedef typename geometry::area_result<Next, default_strategy>::type next_result_t;
  62. typedef typename boost::mpl::if_c
  63. <
  64. boost::is_same
  65. <
  66. curr_result_t,
  67. typename geometry::select_most_precise
  68. <
  69. curr_result_t,
  70. next_result_t
  71. >::type
  72. >::value,
  73. Curr,
  74. Next
  75. >::type type;
  76. };
  77. }} // namespace detail::area
  78. #endif //DOXYGEN_NO_DETAIL
  79. template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
  80. struct area_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, default_strategy>
  81. : geometry::area_result
  82. <
  83. typename geometry::util::select_sequence_element
  84. <
  85. typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
  86. geometry::detail::area::pred_more_precise_default_area_result
  87. >::type,
  88. default_strategy
  89. >
  90. {};
  91. }} // namespace boost::geometry
  92. #endif // BOOST_GEOMETRY_STRATEGIES_AREA_RESULT_HPP