]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/geometries/concepts/geometry_collection_concept.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / geometries / concepts / geometry_collection_concept.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2021, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
10 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP
11 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP
12
13
14 #include <utility>
15
16 #include <boost/concept_check.hpp>
17 #include <boost/range/concepts.hpp>
18
19 #include <boost/geometry/core/geometry_types.hpp>
20 #include <boost/geometry/core/mutable_range.hpp>
21 #include <boost/geometry/core/tag.hpp>
22 #include <boost/geometry/core/tags.hpp>
23 #include <boost/geometry/core/visit.hpp>
24
25 #include <boost/geometry/geometries/concepts/box_concept.hpp>
26 #include <boost/geometry/geometries/concepts/concept_type.hpp>
27 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
28 #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
29 #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
30 #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
31 #include <boost/geometry/geometries/concepts/point_concept.hpp>
32 #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
33 #include <boost/geometry/geometries/concepts/ring_concept.hpp>
34 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
35
36 #include <boost/geometry/util/sequence.hpp>
37 #include <boost/geometry/util/type_traits.hpp>
38
39
40 namespace boost { namespace geometry { namespace concepts
41 {
42
43 namespace detail
44 {
45
46 template
47 <
48 typename Geometry,
49 typename SubGeometry,
50 typename Tag = typename tag<Geometry>::type,
51 bool IsSubDynamicOrCollection = util::is_dynamic_geometry<SubGeometry>::value
52 || util::is_geometry_collection<SubGeometry>::value
53 >
54 struct GeometryType;
55
56 // Prevent recursive concept checking
57 template <typename Geometry, typename SubGeometry, typename Tag>
58 struct GeometryType<Geometry, SubGeometry, Tag, true> {};
59
60 template <typename Geometry, typename SubGeometry, typename Tag>
61 struct GeometryType<Geometry const, SubGeometry, Tag, true> {};
62
63
64 template <typename Geometry, typename SubGeometry>
65 struct GeometryType<Geometry, SubGeometry, geometry_collection_tag, false>
66 : concepts::concept_type<SubGeometry>::type
67 {
68 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
69 BOOST_CONCEPT_USAGE(GeometryType)
70 {
71 Geometry* gc = nullptr;
72 SubGeometry* sg = nullptr;
73 traits::emplace_back<Geometry>::apply(*gc, std::move(*sg));
74 }
75 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
76 };
77
78 template <typename Geometry, typename SubGeometry>
79 struct GeometryType<Geometry const, SubGeometry, geometry_collection_tag, false>
80 : concepts::concept_type<SubGeometry const>::type
81 {};
82
83
84 template <typename Geometry, typename ...SubGeometries>
85 struct GeometryTypesPack {};
86
87 template <typename Geometry, typename SubGeometry, typename ...SubGeometries>
88 struct GeometryTypesPack<Geometry, SubGeometry, SubGeometries...>
89 : GeometryTypesPack<Geometry, SubGeometries...>
90 , GeometryType<Geometry, SubGeometry>
91 {};
92
93
94 template <typename Geometry, typename SubGeometriesSequence>
95 struct GeometryTypes;
96
97 template <typename Geometry, typename ...SubGeometries>
98 struct GeometryTypes<Geometry, util::type_sequence<SubGeometries...>>
99 : GeometryTypesPack<Geometry, SubGeometries...>
100 {};
101
102
103 } // namespace detail
104
105
106 template <typename Geometry>
107 struct GeometryCollection
108 : boost::ForwardRangeConcept<Geometry>
109 {
110 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
111 using sequence_t = typename traits::geometry_types<Geometry>::type;
112 BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry, sequence_t>) );
113
114 BOOST_CONCEPT_USAGE(GeometryCollection)
115 {
116 Geometry* gc = nullptr;
117 traits::clear<Geometry>::apply(*gc);
118 traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
119 }
120 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
121 };
122
123
124 template <typename Geometry>
125 struct ConstGeometryCollection
126 : boost::ForwardRangeConcept<Geometry>
127 {
128 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
129 using sequence_t = typename traits::geometry_types<Geometry>::type;
130 BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry const, sequence_t>) );
131
132 BOOST_CONCEPT_USAGE(ConstGeometryCollection)
133 {
134 Geometry const* gc = nullptr;
135 traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
136 }
137 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
138 };
139
140
141 template <typename Geometry>
142 struct concept_type<Geometry, geometry_collection_tag>
143 {
144 using type = GeometryCollection<Geometry>;
145 };
146
147 template <typename Geometry>
148 struct concept_type<Geometry const, geometry_collection_tag>
149 {
150 using type = ConstGeometryCollection<Geometry>;
151 };
152
153
154 }}} // namespace boost::geometry::concepts
155
156
157 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP