check.hpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  3. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 2020 Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
  14. #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
  15. #include <type_traits>
  16. #include <boost/concept_check.hpp>
  17. #include <boost/concept/requires.hpp>
  18. #include <boost/core/ignore_unused.hpp>
  19. #include <boost/variant/variant_fwd.hpp>
  20. #include <boost/geometry/core/tag.hpp>
  21. #include <boost/geometry/core/tags.hpp>
  22. #include <boost/geometry/geometries/concepts/box_concept.hpp>
  23. #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
  24. #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
  25. #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
  26. #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
  27. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  28. #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
  29. #include <boost/geometry/geometries/concepts/ring_concept.hpp>
  30. #include <boost/geometry/geometries/concepts/segment_concept.hpp>
  31. #include <boost/geometry/algorithms/not_implemented.hpp>
  32. namespace boost { namespace geometry
  33. {
  34. #ifndef DOXYGEN_NO_DETAIL
  35. namespace detail { namespace concept_check
  36. {
  37. template <typename Concept>
  38. class check
  39. {
  40. BOOST_CONCEPT_ASSERT((Concept ));
  41. };
  42. }} // namespace detail::concept_check
  43. #endif // DOXYGEN_NO_DETAIL
  44. #ifndef DOXYGEN_NO_DISPATCH
  45. namespace dispatch
  46. {
  47. template
  48. <
  49. typename Geometry,
  50. typename GeometryTag = typename geometry::tag<Geometry>::type,
  51. bool IsConst = std::is_const<Geometry>::type::value
  52. >
  53. struct check : not_implemented<GeometryTag>
  54. {};
  55. template <typename Geometry>
  56. struct check<Geometry, point_tag, true>
  57. : detail::concept_check::check<concepts::ConstPoint<Geometry> >
  58. {};
  59. template <typename Geometry>
  60. struct check<Geometry, point_tag, false>
  61. : detail::concept_check::check<concepts::Point<Geometry> >
  62. {};
  63. template <typename Geometry>
  64. struct check<Geometry, linestring_tag, true>
  65. : detail::concept_check::check<concepts::ConstLinestring<Geometry> >
  66. {};
  67. template <typename Geometry>
  68. struct check<Geometry, linestring_tag, false>
  69. : detail::concept_check::check<concepts::Linestring<Geometry> >
  70. {};
  71. template <typename Geometry>
  72. struct check<Geometry, ring_tag, true>
  73. : detail::concept_check::check<concepts::ConstRing<Geometry> >
  74. {};
  75. template <typename Geometry>
  76. struct check<Geometry, ring_tag, false>
  77. : detail::concept_check::check<concepts::Ring<Geometry> >
  78. {};
  79. template <typename Geometry>
  80. struct check<Geometry, polygon_tag, true>
  81. : detail::concept_check::check<concepts::ConstPolygon<Geometry> >
  82. {};
  83. template <typename Geometry>
  84. struct check<Geometry, polygon_tag, false>
  85. : detail::concept_check::check<concepts::Polygon<Geometry> >
  86. {};
  87. template <typename Geometry>
  88. struct check<Geometry, box_tag, true>
  89. : detail::concept_check::check<concepts::ConstBox<Geometry> >
  90. {};
  91. template <typename Geometry>
  92. struct check<Geometry, box_tag, false>
  93. : detail::concept_check::check<concepts::Box<Geometry> >
  94. {};
  95. template <typename Geometry>
  96. struct check<Geometry, segment_tag, true>
  97. : detail::concept_check::check<concepts::ConstSegment<Geometry> >
  98. {};
  99. template <typename Geometry>
  100. struct check<Geometry, segment_tag, false>
  101. : detail::concept_check::check<concepts::Segment<Geometry> >
  102. {};
  103. template <typename Geometry>
  104. struct check<Geometry, multi_point_tag, true>
  105. : detail::concept_check::check<concepts::ConstMultiPoint<Geometry> >
  106. {};
  107. template <typename Geometry>
  108. struct check<Geometry, multi_point_tag, false>
  109. : detail::concept_check::check<concepts::MultiPoint<Geometry> >
  110. {};
  111. template <typename Geometry>
  112. struct check<Geometry, multi_linestring_tag, true>
  113. : detail::concept_check::check<concepts::ConstMultiLinestring<Geometry> >
  114. {};
  115. template <typename Geometry>
  116. struct check<Geometry, multi_linestring_tag, false>
  117. : detail::concept_check::check<concepts::MultiLinestring<Geometry> >
  118. {};
  119. template <typename Geometry>
  120. struct check<Geometry, multi_polygon_tag, true>
  121. : detail::concept_check::check<concepts::ConstMultiPolygon<Geometry> >
  122. {};
  123. template <typename Geometry>
  124. struct check<Geometry, multi_polygon_tag, false>
  125. : detail::concept_check::check<concepts::MultiPolygon<Geometry> >
  126. {};
  127. } // namespace dispatch
  128. #endif
  129. namespace concepts
  130. {
  131. #ifndef DOXYGEN_NO_DETAIL
  132. namespace detail
  133. {
  134. template <typename Geometry>
  135. struct checker : dispatch::check<Geometry>
  136. {};
  137. template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
  138. struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
  139. {};
  140. template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
  141. struct checker<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const>
  142. {};
  143. }
  144. #endif // DOXYGEN_NO_DETAIL
  145. /*!
  146. \brief Checks, in compile-time, the concept of any geometry
  147. \ingroup concepts
  148. */
  149. template <typename Geometry>
  150. // workaround for VS2015
  151. #if !defined(_MSC_VER) || (_MSC_VER >= 1910)
  152. constexpr
  153. #endif
  154. inline void check()
  155. {
  156. detail::checker<Geometry> c;
  157. boost::ignore_unused(c);
  158. }
  159. /*!
  160. \brief Checks, in compile-time, the concept of two geometries, and if they
  161. have equal dimensions
  162. \ingroup concepts
  163. */
  164. template <typename Geometry1, typename Geometry2>
  165. // workaround for VS2015
  166. #if !defined(_MSC_VER) || (_MSC_VER >= 1910)
  167. constexpr
  168. #endif
  169. inline void check_concepts_and_equal_dimensions()
  170. {
  171. check<Geometry1>();
  172. check<Geometry2>();
  173. assert_dimension_equal<Geometry1, Geometry2>();
  174. }
  175. } // namespace concepts
  176. }} // namespace boost::geometry
  177. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP