1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
15 #define BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
17 #include <boost/concept/requires.hpp>
18 #include <boost/geometry/geometries/concepts/point_concept.hpp>
19 #include <boost/geometry/util/add_const_if_c.hpp>
21 namespace boost { namespace geometry
24 #ifndef DOXYGEN_NO_DETAIL
28 template <typename Point, int Dimension, int DimensionCount, bool IsConst>
29 struct coordinates_scanner
31 template <typename Op>
32 static inline Op apply(typename add_const_if_c
36 >::type& point, Op operation)
38 operation.template apply<Point, Dimension>(point);
39 return coordinates_scanner
45 >::apply(point, operation);
49 template <typename Point, int DimensionCount, bool IsConst>
50 struct coordinates_scanner<Point, DimensionCount, DimensionCount, IsConst>
52 template <typename Op>
53 static inline Op apply(typename add_const_if_c
57 >::type& , Op operation)
64 #endif // DOXYGEN_NO_DETAIL
66 template <typename Point, typename Op>
67 inline void for_each_coordinate(Point& point, Op operation)
69 BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
71 typedef typename detail::coordinates_scanner
73 Point, 0, dimension<Point>::type::value, false
76 scanner::apply(point, operation);
79 template <typename Point, typename Op>
80 inline Op for_each_coordinate(Point const& point, Op operation)
82 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point>) );
84 typedef typename detail::coordinates_scanner
86 Point, 0, dimension<Point>::type::value, true
89 return scanner::apply(point, operation);
92 }} // namespace boost::geometry
94 #endif // BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP