Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:27

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0004 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2018-2021.
0008 // Modifications copyright (c) 2018-2021, Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0012 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT_HPP
0019 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT_HPP
0020 
0021 
0022 #include <boost/variant/apply_visitor.hpp>
0023 #include <boost/variant/static_visitor.hpp>
0024 #include <boost/variant/variant.hpp>
0025 //#include <boost/variant/variant_fwd.hpp>
0026 
0027 #include <boost/geometry/core/geometry_types.hpp>
0028 #include <boost/geometry/core/point_type.hpp>
0029 #include <boost/geometry/core/tag.hpp>
0030 #include <boost/geometry/core/tags.hpp>
0031 #include <boost/geometry/core/visit.hpp>
0032 #include <boost/geometry/util/sequence.hpp>
0033 
0034 
0035 namespace boost { namespace geometry
0036 {
0037 
0038 namespace detail
0039 {
0040 
0041 template <typename Seq, typename ResultSeq = util::type_sequence<>>
0042 struct boost_variant_types;
0043 
0044 template <typename T, typename ...Ts, typename ...Rs>
0045 struct boost_variant_types<util::type_sequence<T, Ts...>, util::type_sequence<Rs...>>
0046 {
0047     using type = typename boost_variant_types<util::type_sequence<Ts...>, util::type_sequence<Rs..., T>>::type;
0048 };
0049 
0050 template <typename ...Ts, typename ...Rs>
0051 struct boost_variant_types<util::type_sequence<boost::detail::variant::void_, Ts...>, util::type_sequence<Rs...>>
0052 {
0053     using type = util::type_sequence<Rs...>;
0054 };
0055 
0056 template <typename ...Rs>
0057 struct boost_variant_types<util::type_sequence<>, util::type_sequence<Rs...>>
0058 {
0059     using type = util::type_sequence<Rs...>;
0060 };
0061 
0062 
0063 } // namespace detail
0064 
0065 
0066 // TODO: This is not used anywhere in the header files. Only in tests.
0067 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0068 struct point_type<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
0069     : point_type
0070         <
0071             typename util::pack_front
0072                 <
0073                     BOOST_VARIANT_ENUM_PARAMS(T)
0074                 >::type
0075         >
0076 {};
0077 
0078 
0079 namespace traits
0080 {
0081 
0082 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0083 struct tag<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
0084 {
0085     using type = dynamic_geometry_tag;
0086 };
0087 
0088 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0089 struct visit<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
0090 {
0091     template <typename Function>
0092     struct visitor
0093         : boost::static_visitor<>
0094     {
0095         visitor(Function function)
0096             : m_function(function)
0097         {}
0098 
0099         template <typename Geometry>
0100         void operator()(Geometry && geometry)
0101         {
0102             m_function(std::forward<Geometry>(geometry));
0103         }
0104 
0105         Function m_function;
0106     };
0107 
0108     template <typename Function, typename Variant>
0109     static void apply(Function function, Variant && variant)
0110     {
0111         visitor<Function> visitor(function);
0112         boost::apply_visitor(visitor, std::forward<Variant>(variant));
0113     }
0114 };
0115 
0116 template <BOOST_VARIANT_ENUM_PARAMS(typename T), BOOST_VARIANT_ENUM_PARAMS(typename U)>
0117 struct visit<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)>>
0118 {
0119     template <typename Function>
0120     struct visitor
0121         : boost::static_visitor<>
0122     {
0123         visitor(Function function)
0124             : m_function(function)
0125         {}
0126 
0127         template <typename Geometry1, typename Geometry2>
0128         void operator()(Geometry1 && geometry1, Geometry2 && geometry2)
0129         {
0130             m_function(std::forward<Geometry1>(geometry1),
0131                        std::forward<Geometry2>(geometry2));
0132         }
0133 
0134         Function m_function;
0135     };
0136 
0137     template <typename Function, typename Variant1, typename Variant2>
0138     static void apply(Function function, Variant1 && variant1, Variant2 && variant2)
0139     {
0140         visitor<Function> visitor(function);
0141         boost::apply_visitor(visitor,
0142                              std::forward<Variant1>(variant1),
0143                              std::forward<Variant2>(variant2));
0144     }
0145 };
0146 
0147 
0148 #ifdef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
0149 
0150 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0151 struct geometry_types<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
0152 {
0153     using type = typename geometry::detail::boost_variant_types
0154         <
0155             util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>
0156         >::type;
0157 };
0158 
0159 #else // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
0160 
0161 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0162 struct geometry_types<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
0163 {
0164     using type = util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>;
0165 };
0166 
0167 #endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
0168 
0169 } // namespace traits
0170 
0171 
0172 }} // namespace boost::geometry
0173 
0174 
0175 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT_HPP