Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:51:57

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2024 Adam Wulkiewicz, Lodz, Poland.
0004 
0005 // Copyright (c) 2020-2021, Oracle and/or its affiliates.
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
0010 
0011 #ifndef BOOST_GEOMETRY_UTIL_TYPE_TRAITS_HPP
0012 #define BOOST_GEOMETRY_UTIL_TYPE_TRAITS_HPP
0013 
0014 
0015 #include <boost/geometry/core/tag.hpp>
0016 #include <boost/geometry/core/tags.hpp>
0017 #include <boost/geometry/util/type_traits_std.hpp>
0018 
0019 
0020 namespace boost { namespace geometry
0021 {
0022 
0023 
0024 namespace util
0025 {
0026 
0027 
0028 template <typename T>
0029 struct is_geometry
0030     : bool_constant<! std::is_void<tag_t<T>>::value>
0031 {};
0032 
0033 template <typename T>
0034 struct is_not_geometry
0035     : std::is_void<tag_t<T>>
0036 {};
0037 
0038 #ifndef BOOST_NO_CXX17_INLINE_VARIABLES
0039 template <typename T>
0040 inline constexpr bool is_geometry_v = is_geometry<T>::value;
0041 template <typename T>
0042 inline constexpr bool is_not_geometry_v = is_not_geometry<T>::value;
0043 #endif
0044 
0045 template <typename T>
0046 struct is_point
0047     : std::is_same<point_tag, tag_t<T>>
0048 {};
0049 
0050 template <typename T>
0051 struct is_multi_point
0052     : std::is_same<multi_point_tag, tag_t<T>>
0053 {};
0054 
0055 template <typename T>
0056 struct is_pointlike
0057     : std::is_base_of<pointlike_tag, tag_t<T>>
0058 {};
0059 
0060 #ifndef BOOST_NO_CXX17_INLINE_VARIABLES
0061 template <typename T>
0062 inline constexpr bool is_point_v = is_point<T>::value;
0063 template <typename T>
0064 inline constexpr bool is_multi_point_v = is_multi_point<T>::value;
0065 template <typename T>
0066 inline constexpr bool is_pointlike_v = is_pointlike<T>::value;
0067 #endif
0068 
0069 
0070 template <typename T>
0071 struct is_segment
0072     : std::is_same<segment_tag, tag_t<T>>
0073 {};
0074 
0075 template <typename T>
0076 struct is_linestring
0077     : std::is_same<linestring_tag, tag_t<T>>
0078 {};
0079 
0080 template <typename T>
0081 struct is_multi_linestring
0082     : std::is_same<multi_linestring_tag, tag_t<T>>
0083 {};
0084 
0085 template <typename T>
0086 struct is_polylinear
0087     : std::is_base_of<polylinear_tag, tag_t<T>>
0088 {};
0089 
0090 template <typename T>
0091 struct is_linear
0092     : std::is_base_of<linear_tag, tag_t<T>>
0093 {};
0094 
0095 #ifndef BOOST_NO_CXX17_INLINE_VARIABLES
0096 template <typename T>
0097 inline constexpr bool is_segment_v = is_segment<T>::value;
0098 template <typename T>
0099 inline constexpr bool is_linestring_v = is_linestring<T>::value;
0100 template <typename T>
0101 inline constexpr bool is_multi_linestring_v = is_multi_linestring<T>::value;
0102 template <typename T>
0103 inline constexpr bool is_polylinear_v = is_polylinear<T>::value;
0104 template <typename T>
0105 inline constexpr bool is_linear_v = is_linear<T>::value;
0106 #endif
0107 
0108 
0109 template <typename T>
0110 struct is_box
0111     : std::is_same<box_tag, tag_t<T>>
0112 {};
0113 
0114 template <typename T>
0115 struct is_ring
0116     : std::is_same<ring_tag, tag_t<T>>
0117 {};
0118 
0119 template <typename T>
0120 struct is_polygon
0121     : std::is_same<polygon_tag, tag_t<T>>
0122 {};
0123 
0124 template <typename T>
0125 struct is_multi_polygon
0126     : std::is_same<multi_polygon_tag, tag_t<T>>
0127 {};
0128 
0129 template <typename T>
0130 struct is_polygonal
0131     : std::is_base_of<polygonal_tag, tag_t<T>>
0132 {};
0133 
0134 template <typename T>
0135 struct is_areal
0136     : std::is_base_of<areal_tag, tag_t<T>>
0137 {};
0138 
0139 #ifndef BOOST_NO_CXX17_INLINE_VARIABLES
0140 template <typename T>
0141 inline constexpr bool is_box_v = is_box<T>::value;
0142 template <typename T>
0143 inline constexpr bool is_ring_v = is_ring<T>::value;
0144 template <typename T>
0145 inline constexpr bool is_polygon_v = is_polygon<T>::value;
0146 template <typename T>
0147 inline constexpr bool is_multi_polygon_v = is_multi_polygon<T>::value;
0148 template <typename T>
0149 inline constexpr bool is_polygonal_v = is_polygonal<T>::value;
0150 template <typename T>
0151 inline constexpr bool is_areal_v = is_areal<T>::value;
0152 #endif
0153 
0154 
0155 template <typename T>
0156 struct is_segmental
0157     : bool_constant<is_linear<T>::value || is_polygonal<T>::value>
0158 {};
0159 
0160 template <typename T>
0161 struct is_polysegmental
0162     : bool_constant<is_polylinear<T>::value || is_polygonal<T>::value>
0163 {};
0164 
0165 template <typename T>
0166 struct is_multi
0167     : std::is_base_of<multi_tag, tag_t<T>>
0168 {};
0169 
0170 template <typename T>
0171 struct is_multi_element
0172     : bool_constant<is_point<T>::value || is_linestring<T>::value || is_polygon<T>::value>
0173 {};
0174 
0175 template <typename T>
0176 struct is_single
0177     : std::is_base_of<single_tag, tag_t<T>>
0178 {};
0179 
0180 template <typename T>
0181 struct is_geometry_collection
0182     : std::is_same<geometry_collection_tag, tag_t<T>>
0183 {};
0184 
0185 template <typename T>
0186 struct is_dynamic_geometry
0187     : std::is_same<dynamic_geometry_tag, tag_t<T>>
0188 {};
0189 
0190 #ifndef BOOST_NO_CXX17_INLINE_VARIABLES
0191 template <typename T>
0192 inline constexpr bool is_segmental_v = is_segmental<T>::value;
0193 template <typename T>
0194 inline constexpr bool is_polysegmental_v = is_polysegmental<T>::value;
0195 template <typename T>
0196 inline constexpr bool is_multi_v = is_multi<T>::value;
0197 template <typename T>
0198 inline constexpr bool is_multi_element_v = is_multi_element<T>::value;
0199 template <typename T>
0200 inline constexpr bool is_single_v = is_single<T>::value;
0201 template <typename T>
0202 inline constexpr bool is_geometry_collection_v = is_geometry_collection<T>::value;
0203 template <typename T>
0204 inline constexpr bool is_dynamic_geometry_v = is_dynamic_geometry<T>::value;
0205 #endif
0206 
0207 
0208 template <typename Geometry, typename T = void>
0209 struct enable_if_point
0210     : std::enable_if<is_point<Geometry>::value, T>
0211 {};
0212 
0213 template <typename Geometry, typename T = void>
0214 using enable_if_point_t = typename enable_if_point<Geometry, T>::type;
0215 
0216 
0217 template <typename Geometry, typename T = void>
0218 struct enable_if_multi_point
0219     : std::enable_if<is_multi_point<Geometry>::value, T>
0220 {};
0221 
0222 template <typename Geometry, typename T = void>
0223 using enable_if_multi_point_t = typename enable_if_multi_point<Geometry, T>::type;
0224 
0225 template <typename Geometry, typename T = void>
0226 struct enable_if_pointlike
0227     : std::enable_if<is_pointlike<Geometry>::value, T>
0228 {};
0229 
0230 template <typename Geometry, typename T = void>
0231 using enable_if_pointlike_t = typename enable_if_pointlike<Geometry, T>::type;
0232 
0233 
0234 template <typename Geometry, typename T = void>
0235 struct enable_if_segment
0236     : std::enable_if<is_segment<Geometry>::value, T>
0237 {};
0238 
0239 template <typename Geometry, typename T = void>
0240 using enable_if_segment_t = typename enable_if_segment<Geometry, T>::type;
0241 
0242 template <typename Geometry, typename T = void>
0243 struct enable_if_linestring
0244     : std::enable_if<is_linestring<Geometry>::value, T>
0245 {};
0246 
0247 template <typename Geometry, typename T = void>
0248 using enable_if_linestring_t = typename enable_if_linestring<Geometry, T>::type;
0249 
0250 template <typename Geometry, typename T = void>
0251 struct enable_if_multi_linestring
0252     : std::enable_if<is_multi_linestring<Geometry>::value, T>
0253 {};
0254 
0255 template <typename Geometry, typename T = void>
0256 using enable_if_multi_linestring_t = typename enable_if_multi_linestring<Geometry, T>::type;
0257 
0258 
0259 template <typename Geometry, typename T = void>
0260 struct enable_if_polylinear
0261     : std::enable_if<is_polylinear<Geometry>::value, T>
0262 {};
0263 
0264 template <typename Geometry, typename T = void>
0265 using enable_if_polylinear_t = typename enable_if_polylinear<Geometry, T>::type;
0266 
0267 
0268 template <typename Geometry, typename T = void>
0269 struct enable_if_linear
0270     : std::enable_if<is_linear<Geometry>::value, T>
0271 {};
0272 
0273 template <typename Geometry, typename T = void>
0274 using enable_if_linear_t = typename enable_if_linear<Geometry, T>::type;
0275 
0276 
0277 template <typename Geometry, typename T = void>
0278 struct enable_if_box
0279     : std::enable_if<is_box<Geometry>::value, T>
0280 {};
0281 
0282 template <typename Geometry, typename T = void>
0283 using enable_if_box_t = typename enable_if_box<Geometry, T>::type;
0284 
0285 template <typename Geometry, typename T = void>
0286 struct enable_if_ring
0287     : std::enable_if<is_ring<Geometry>::value, T>
0288 {};
0289 
0290 template <typename Geometry, typename T = void>
0291 using enable_if_ring_t = typename enable_if_ring<Geometry, T>::type;
0292 
0293 template <typename Geometry, typename T = void>
0294 struct enable_if_polygon
0295     : std::enable_if<is_polygon<Geometry>::value, T>
0296 {};
0297 
0298 template <typename Geometry, typename T = void>
0299 using enable_if_polygon_t = typename enable_if_polygon<Geometry, T>::type;
0300 
0301 template <typename Geometry, typename T = void>
0302 struct enable_if_multi_polygon
0303     : std::enable_if<is_multi_polygon<Geometry>::value, T>
0304 {};
0305 
0306 template <typename Geometry, typename T = void>
0307 using enable_if_multi_polygon_t = typename enable_if_multi_polygon<Geometry, T>::type;
0308 
0309 
0310 template <typename Geometry, typename T = void>
0311 struct enable_if_polygonal
0312     : std::enable_if<is_polygonal<Geometry>::value, T>
0313 {};
0314 
0315 template <typename Geometry, typename T = void>
0316 using enable_if_polygonal_t = typename enable_if_polygonal<Geometry, T>::type;
0317 
0318 
0319 template <typename Geometry, typename T = void>
0320 struct enable_if_areal
0321     : std::enable_if<is_areal<Geometry>::value, T>
0322 {};
0323 
0324 template <typename Geometry, typename T = void>
0325 using enable_if_areal_t = typename enable_if_areal<Geometry, T>::type;
0326 
0327 
0328 template <typename Geometry, typename T = void>
0329 struct enable_if_polysegmental
0330     : std::enable_if<is_polysegmental<Geometry>::value, T>
0331 {};
0332 
0333 template <typename Geometry, typename T = void>
0334 using enable_if_polysegmental_t = typename enable_if_polysegmental<Geometry, T>::type;
0335 
0336 
0337 template <typename Geometry, typename T = void>
0338 struct enable_if_dynamic_geometry
0339     : std::enable_if<is_dynamic_geometry<Geometry>::value, T>
0340 {};
0341 
0342 template <typename Geometry, typename T = void>
0343 using enable_if_dynamic_geometry_t = typename enable_if_dynamic_geometry<Geometry, T>::type;
0344 
0345 template <typename Geometry, typename T = void>
0346 struct enable_if_geometry_collection
0347     : std::enable_if<is_geometry_collection<Geometry>::value, T>
0348 {};
0349 
0350 template <typename Geometry, typename T = void>
0351 using enable_if_geometry_collection_t = typename enable_if_geometry_collection<Geometry, T>::type;
0352 
0353 
0354 } // namespace util
0355 
0356 
0357 // Deprecated utilities, defined for backward compatibility but might be
0358 // removed in the future.
0359 
0360 
0361 /*!
0362     \brief Meta-function defining "true" for areal types (box, (multi)polygon, ring),
0363     \note Used for tag dispatching and meta-function finetuning
0364     \note Also a "ring" has areal properties within Boost.Geometry
0365     \ingroup core
0366 */
0367 template <typename T>
0368 using is_areal [[deprecated("Use util::is_areal<> instead.")]] = util::is_areal<T>;
0369 
0370 
0371 }} // namespace boost::geometry
0372 
0373 #endif // BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP