File indexing completed on 2025-01-18 09:36:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
0019 #define BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
0020
0021 #include <boost/concept/requires.hpp>
0022 #include <boost/geometry/geometries/concepts/point_concept.hpp>
0023
0024 namespace boost { namespace geometry
0025 {
0026
0027 #ifndef DOXYGEN_NO_DETAIL
0028 namespace detail
0029 {
0030
0031 template
0032 <
0033 typename Point,
0034 int Dimension = 0,
0035 int DimensionCount = dimension<Point>::value
0036 >
0037 struct coordinates_scanner
0038 {
0039 template <typename Op>
0040 static inline Op apply(Point& point, Op operation)
0041 {
0042 operation.template apply<Point, Dimension>(point);
0043 return coordinates_scanner
0044 <
0045 Point,
0046 Dimension + 1
0047 >::apply(point, operation);
0048 }
0049 };
0050
0051 template <typename Point, int DimensionCount>
0052 struct coordinates_scanner<Point, DimensionCount, DimensionCount>
0053 {
0054 template <typename Op>
0055 static inline Op apply(Point& , Op operation)
0056 {
0057 return operation;
0058 }
0059 };
0060
0061 }
0062 #endif
0063
0064 template <typename Point, typename Op>
0065 inline void for_each_coordinate(Point& point, Op operation)
0066 {
0067 BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
0068
0069 detail::coordinates_scanner<Point>::apply(point, operation);
0070 }
0071
0072 template <typename Point, typename Op>
0073 inline Op for_each_coordinate(Point const& point, Op operation)
0074 {
0075 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point>) );
0076
0077 return detail::coordinates_scanner<Point const>::apply(point, operation);
0078 }
0079
0080 }}
0081
0082 #endif