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