Warning, file /include/boost/geometry/algorithms/num_geometries.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 = tag_cast_t<tag_t<Geometry>, single_tag, multi_tag>
0055 >
0056 struct num_geometries: not_implemented<Tag>
0057 {};
0058
0059
0060 template <typename Geometry>
0061 struct num_geometries<Geometry, single_tag>
0062 : detail::counting::other_count<1>
0063 {};
0064
0065
0066 template <typename MultiGeometry>
0067 struct num_geometries<MultiGeometry, multi_tag>
0068 {
0069 static inline std::size_t apply(MultiGeometry const& multi_geometry)
0070 {
0071 return boost::size(multi_geometry);
0072 }
0073 };
0074
0075
0076 }
0077 #endif
0078
0079
0080 namespace resolve_variant
0081 {
0082
0083 template <typename Geometry>
0084 struct num_geometries
0085 {
0086 static inline std::size_t apply(Geometry const& geometry)
0087 {
0088 concepts::check<Geometry const>();
0089
0090 return dispatch::num_geometries<Geometry>::apply(geometry);
0091 }
0092 };
0093
0094 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0095 struct num_geometries<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
0096 {
0097 struct visitor: boost::static_visitor<std::size_t>
0098 {
0099 template <typename Geometry>
0100 inline std::size_t operator()(Geometry const& geometry) const
0101 {
0102 return num_geometries<Geometry>::apply(geometry);
0103 }
0104 };
0105
0106 static inline std::size_t
0107 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
0108 {
0109 return boost::apply_visitor(visitor(), geometry);
0110 }
0111 };
0112
0113 }
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 template <typename Geometry>
0127 inline std::size_t num_geometries(Geometry const& geometry)
0128 {
0129 return resolve_variant::num_geometries<Geometry>::apply(geometry);
0130 }
0131
0132
0133 }}
0134
0135
0136 #endif