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