]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/util/for_each_coordinate.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / util / for_each_coordinate.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
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.
6
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
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)
13
14 #ifndef BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
15 #define BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
16
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>
20
21 namespace boost { namespace geometry
22 {
23
24 #ifndef DOXYGEN_NO_DETAIL
25 namespace detail
26 {
27
28 template <typename Point, int Dimension, int DimensionCount, bool IsConst>
29 struct coordinates_scanner
30 {
31 template <typename Op>
32 static inline Op apply(typename add_const_if_c
33 <
34 IsConst,
35 Point
36 >::type& point, Op operation)
37 {
38 operation.template apply<Point, Dimension>(point);
39 return coordinates_scanner
40 <
41 Point,
42 Dimension+1,
43 DimensionCount,
44 IsConst
45 >::apply(point, operation);
46 }
47 };
48
49 template <typename Point, int DimensionCount, bool IsConst>
50 struct coordinates_scanner<Point, DimensionCount, DimensionCount, IsConst>
51 {
52 template <typename Op>
53 static inline Op apply(typename add_const_if_c
54 <
55 IsConst,
56 Point
57 >::type& , Op operation)
58 {
59 return operation;
60 }
61 };
62
63 } // namespace detail
64 #endif // DOXYGEN_NO_DETAIL
65
66 template <typename Point, typename Op>
67 inline void for_each_coordinate(Point& point, Op operation)
68 {
69 BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
70
71 typedef typename detail::coordinates_scanner
72 <
73 Point, 0, dimension<Point>::type::value, false
74 > scanner;
75
76 scanner::apply(point, operation);
77 }
78
79 template <typename Point, typename Op>
80 inline Op for_each_coordinate(Point const& point, Op operation)
81 {
82 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point>) );
83
84 typedef typename detail::coordinates_scanner
85 <
86 Point, 0, dimension<Point>::type::value, true
87 > scanner;
88
89 return scanner::apply(point, operation);
90 }
91
92 }} // namespace boost::geometry
93
94 #endif // BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP