// 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_GEOMETRIES_ADAPTED_DETAIL_ANY_HPP #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_DETAIL_ANY_HPP #include #include #include namespace boost { namespace geometry { namespace detail { template < typename CastPolicy, typename TypeSequence, std::size_t N = util::sequence_size::value > struct visit_any { static const std::size_t M = N / 2; template static bool apply(Function && function, Any && any) { return visit_any::template apply( std::forward(function), std::forward(any)) || visit_any::template apply( std::forward(function), std::forward(any)); } }; template struct visit_any { template static bool apply(Function && function, Any && any) { using elem_t = typename util::sequence_element::type; using geom_t = util::transcribe_const_t, elem_t>; geom_t * g = CastPolicy::template apply(&any); if (g != nullptr) { using geom_ref_t = std::conditional_t < std::is_rvalue_reference::value, geom_t&&, geom_t& >; function(static_cast(*g)); return true; } else { return false; } } }; template struct visit_any { template static bool apply(Function &&, Any &&) { return false; } }; } // namespace detail }} // namespace boost::geometry #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_DETAIL_ANY_HPP