From 0ed2885ececf079f16b42fec60a4dc86285b5101 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Wed, 7 Nov 2018 11:06:42 +0900 Subject: add tbtnavi source --- include/mapbox/geometry/for_each_point.hpp | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/mapbox/geometry/for_each_point.hpp (limited to 'include/mapbox/geometry/for_each_point.hpp') diff --git a/include/mapbox/geometry/for_each_point.hpp b/include/mapbox/geometry/for_each_point.hpp new file mode 100644 index 0000000..44d6e77 --- /dev/null +++ b/include/mapbox/geometry/for_each_point.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include + +namespace mapbox { +namespace geometry { + +template +auto for_each_point(Point&& point, F&& f) + -> decltype(point.x, point.y, void()) +{ + f(std::forward(point)); +} + +template +auto for_each_point(Container&& container, F&& f) + -> decltype(container.begin(), container.end(), void()); + +template +void for_each_point(mapbox::util::variant const& geom, F&& f) +{ + mapbox::util::variant::visit(geom, [&] (auto const& g) { + for_each_point(g, f); + }); +} + +template +void for_each_point(mapbox::util::variant & geom, F&& f) +{ + mapbox::util::variant::visit(geom, [&] (auto & g) { + for_each_point(g, f); + }); +} + +template +auto for_each_point(Container&& container, F&& f) + -> decltype(container.begin(), container.end(), void()) +{ + for (auto& e: container) { + for_each_point(e, f); + } +} + +} // namespace geometry +} // namespace mapbox -- cgit