Back to home page

EIC code displayed by LXR

 
 

    


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 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2014-2020.
0008 // Modifications copyright (c) 2014-2020, Oracle and/or its affiliates.
0009 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 
0012 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0013 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0014 
0015 // Use, modification and distribution is subject to the Boost Software License,
0016 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
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 } // namespace dispatch
0077 #endif // DOXYGEN_NO_DISPATCH
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 } // namespace resolve_variant
0114 
0115 
0116 /*!
0117 \brief \brief_calc{number of geometries}
0118 \ingroup num_geometries
0119 \details \details_calc{num_geometries, number of geometries}.
0120 \tparam Geometry \tparam_geometry
0121 \param geometry \param_geometry
0122 \return \return_calc{number of geometries}
0123 
0124 \qbk{[include reference/algorithms/num_geometries.qbk]}
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 }} // namespace boost::geometry
0134 
0135 
0136 #endif // BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP