File indexing completed on 2025-01-18 09:35:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
0014 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
0015
0016 #include <type_traits>
0017
0018 #include <boost/geometry/core/assert.hpp>
0019 #include <boost/geometry/core/tag.hpp>
0020 #include <boost/geometry/util/range.hpp>
0021
0022 namespace boost { namespace geometry {
0023
0024 #ifndef DOXYGEN_NO_DISPATCH
0025 namespace detail_dispatch {
0026
0027
0028
0029 template
0030 <
0031 typename Geometry,
0032 bool IsMulti = std::is_base_of
0033 <
0034 multi_tag,
0035 typename geometry::tag<Geometry>::type
0036 >::value
0037 >
0038 struct single_geometry
0039 {
0040 typedef Geometry & return_type;
0041
0042 template <typename Id>
0043 static inline return_type apply(Geometry & g, Id const& ) { return g; }
0044 };
0045
0046
0047 template <typename Geometry>
0048 struct single_geometry<Geometry, true>
0049 {
0050 typedef typename boost::range_reference<Geometry>::type return_type;
0051
0052 template <typename Id>
0053 static inline return_type apply(Geometry & g, Id const& id)
0054 {
0055 BOOST_GEOMETRY_ASSERT(id.multi_index >= 0);
0056 typedef typename boost::range_size<Geometry>::type size_type;
0057 return range::at(g, static_cast<size_type>(id.multi_index));
0058 }
0059 };
0060
0061 }
0062 #endif
0063
0064 #ifndef DOXYGEN_NO_DETAIL
0065 namespace detail {
0066
0067 template <typename Geometry>
0068 struct single_geometry_return_type
0069 {
0070 typedef typename detail_dispatch::single_geometry<Geometry>::return_type type;
0071 };
0072
0073 template <typename Geometry, typename Id>
0074 inline
0075 typename single_geometry_return_type<Geometry>::type
0076 single_geometry(Geometry & geometry, Id const& id)
0077 {
0078 return detail_dispatch::single_geometry<Geometry>::apply(geometry, id);
0079 }
0080
0081 template <typename Geometry, typename Id>
0082 inline
0083 typename single_geometry_return_type<Geometry const>::type
0084 single_geometry(Geometry const& geometry, Id const& id)
0085 {
0086 return detail_dispatch::single_geometry<Geometry const>::apply(geometry, id);
0087 }
0088
0089 }
0090 #endif
0091
0092 }}
0093
0094 #endif