File indexing completed on 2024-11-15 09:10:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
0021 #define BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
0022
0023 #include <cstddef>
0024
0025 #include <boost/range/size.hpp>
0026
0027 #include <boost/variant/apply_visitor.hpp>
0028 #include <boost/variant/static_visitor.hpp>
0029 #include <boost/variant/variant_fwd.hpp>
0030
0031 #include <boost/geometry/algorithms/not_implemented.hpp>
0032
0033 #include <boost/geometry/core/tag.hpp>
0034 #include <boost/geometry/core/tags.hpp>
0035 #include <boost/geometry/core/tag_cast.hpp>
0036
0037 #include <boost/geometry/geometries/concepts/check.hpp>
0038
0039 #include <boost/geometry/algorithms/detail/counting.hpp>
0040
0041
0042 namespace boost { namespace geometry
0043 {
0044
0045
0046 #ifndef DOXYGEN_NO_DISPATCH
0047 namespace dispatch
0048 {
0049
0050
0051 template
0052 <
0053 typename Geometry,
0054 typename Tag = typename tag_cast
0055 <
0056 typename tag<Geometry>::type,
0057 single_tag,
0058 multi_tag
0059 >::type
0060 >
0061 struct num_geometries: not_implemented<Tag>
0062 {};
0063
0064
0065 template <typename Geometry>
0066 struct num_geometries<Geometry, single_tag>
0067 : detail::counting::other_count<1>
0068 {};
0069
0070
0071 template <typename MultiGeometry>
0072 struct num_geometries<MultiGeometry, multi_tag>
0073 {
0074 static inline std::size_t apply(MultiGeometry const& multi_geometry)
0075 {
0076 return boost::size(multi_geometry);
0077 }
0078 };
0079
0080
0081 }
0082 #endif
0083
0084
0085 namespace resolve_variant
0086 {
0087
0088 template <typename Geometry>
0089 struct num_geometries
0090 {
0091 static inline std::size_t apply(Geometry const& geometry)
0092 {
0093 concepts::check<Geometry const>();
0094
0095 return dispatch::num_geometries<Geometry>::apply(geometry);
0096 }
0097 };
0098
0099 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0100 struct num_geometries<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
0101 {
0102 struct visitor: boost::static_visitor<std::size_t>
0103 {
0104 template <typename Geometry>
0105 inline std::size_t operator()(Geometry const& geometry) const
0106 {
0107 return num_geometries<Geometry>::apply(geometry);
0108 }
0109 };
0110
0111 static inline std::size_t
0112 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
0113 {
0114 return boost::apply_visitor(visitor(), geometry);
0115 }
0116 };
0117
0118 }
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 template <typename Geometry>
0132 inline std::size_t num_geometries(Geometry const& geometry)
0133 {
0134 return resolve_variant::num_geometries<Geometry>::apply(geometry);
0135 }
0136
0137
0138 }}
0139
0140
0141 #endif