12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #ifndef BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
- #define BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
- #include <boost/concept/requires.hpp>
- #include <boost/geometry/geometries/concepts/point_concept.hpp>
- namespace boost { namespace geometry
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
- template
- <
- typename Point,
- int Dimension = 0,
- int DimensionCount = dimension<Point>::value
- >
- struct coordinates_scanner
- {
- template <typename Op>
- static inline Op apply(Point& point, Op operation)
- {
- operation.template apply<Point, Dimension>(point);
- return coordinates_scanner
- <
- Point,
- Dimension + 1
- >::apply(point, operation);
- }
- };
- template <typename Point, int DimensionCount>
- struct coordinates_scanner<Point, DimensionCount, DimensionCount>
- {
- template <typename Op>
- static inline Op apply(Point& , Op operation)
- {
- return operation;
- }
- };
- }
- #endif
- template <typename Point, typename Op>
- inline void for_each_coordinate(Point& point, Op operation)
- {
- BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
- detail::coordinates_scanner<Point>::apply(point, operation);
- }
- template <typename Point, typename Op>
- inline Op for_each_coordinate(Point const& point, Op operation)
- {
- BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point>) );
- return detail::coordinates_scanner<Point const>::apply(point, operation);
- }
- }}
- #endif
|