1 #pragma once
2
3 #include <mapbox/geometry/geometry.hpp>
4
5 namespace mapbox {
6 namespace geometry {
7
8 template <typename Point, typename F>
for_each_point(Point && point,F && f)9 auto for_each_point(Point&& point, F&& f)
10 -> decltype(point.x, point.y, void())
11 {
12 f(std::forward<Point>(point));
13 }
14
15 template <typename Container, typename F>
16 auto for_each_point(Container&& container, F&& f)
17 -> decltype(container.begin(), container.end(), void());
18
19 template <typename...Types, typename F>
for_each_point(mapbox::util::variant<Types...> const & geom,F && f)20 void for_each_point(mapbox::util::variant<Types...> const& geom, F&& f)
21 {
22 mapbox::util::variant<Types...>::visit(geom, [&] (auto const& g) {
23 for_each_point(g, f);
24 });
25 }
26
27 template <typename...Types, typename F>
for_each_point(mapbox::util::variant<Types...> & geom,F && f)28 void for_each_point(mapbox::util::variant<Types...> & geom, F&& f)
29 {
30 mapbox::util::variant<Types...>::visit(geom, [&] (auto & g) {
31 for_each_point(g, f);
32 });
33 }
34
35 template <typename Container, typename F>
for_each_point(Container && container,F && f)36 auto for_each_point(Container&& container, F&& f)
37 -> decltype(container.begin(), container.end(), void())
38 {
39 for (auto& e: container) {
40 for_each_point(e, f);
41 }
42 }
43
44 } // namespace geometry
45 } // namespace mapbox
46