// Boost.Geometry // Copyright (c) 2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_CORE_VISIT_HPP #define BOOST_GEOMETRY_CORE_VISIT_HPP #include #include #include #include namespace boost { namespace geometry { namespace traits { // TODO: Alternatives: // - free function // template // auto visit(Visitor &&, Variants && ...) {} // // - additional Enable tparam // template // struct visit {}; template struct visit { BOOST_GEOMETRY_STATIC_ASSERT_FALSE( "Not implemented for these DynamicGeometries types.", DynamicGeometries...); }; // By default call 1-parameter visit for each geometry template struct visit { template static void apply(Function && function, Variant1 && variant1, Variant2 && variant2) { visit>::apply([&](auto && g1) { using ref1_t = decltype(g1); visit>::apply([&](auto && g2) { function(std::forward(g1), std::forward(g2)); }, std::forward(variant2)); }, std::forward(variant1)); } }; // By default treat GeometryCollection as a range of DynamicGeometries template struct iter_visit { template static void apply(Function && function, Iterator iterator) { using value_t = typename boost::range_value::type; using reference_t = typename std::iterator_traits::reference; visit::apply(std::forward(function), std::forward(*iterator)); } }; }}} // namespace boost::geometry::traits #endif // BOOST_GEOMETRY_CORE_VISIT_HPP