1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. 6 7 // This file was modified by Oracle on 2015. 8 // Modifications copyright (c) 2015, Oracle and/or its affiliates. 9 10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 11 12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 14 15 // Use, modification and distribution is subject to the Boost Software License, 16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 17 // http://www.boost.org/LICENSE_1_0.txt) 18 19 #ifndef BOOST_GEOMETRY_UTIL_TRANSFORM_VARIANT_HPP 20 #define BOOST_GEOMETRY_UTIL_TRANSFORM_VARIANT_HPP 21 22 23 #include <boost/mpl/transform.hpp> 24 #include <boost/variant/variant_fwd.hpp> 25 26 27 namespace boost { namespace geometry 28 { 29 30 31 /*! 32 \brief Meta-function that takes a Sequence type, an MPL lambda 33 expression and an optional Inserter and returns a variant type over 34 the same types as the initial variant type, each transformed using 35 the lambda expression. 36 \ingroup utility 37 \par Example 38 \code 39 typedef boost::mpl::vector<int, float, long> types; 40 typedef transform_variant<types, add_pointer<_> > transformed; 41 typedef variant<int*, float*, long*> result; 42 BOOST_MPL_ASSERT(( equal<result, transformed> )); 43 \endcode 44 */ 45 template <typename Sequence, typename Op, typename In = boost::mpl::na> 46 struct transform_variant: 47 make_variant_over< 48 typename boost::mpl::transform< 49 Sequence, 50 Op, 51 In 52 >::type 53 > 54 {}; 55 56 57 /*! 58 \brief Meta-function that takes a boost::variant type and an MPL lambda 59 expression and returns a variant type over the same types as the 60 initial variant type, each transformed using the lambda expression. 61 \ingroup utility 62 \par Example 63 \code 64 typedef variant<int, float, long> variant_type; 65 typedef transform_variant<variant_type, add_pointer<_> > transformed; 66 typedef variant<int*, float*, long*> result; 67 BOOST_MPL_ASSERT(( equal<result, transformed> )); 68 \endcode 69 */ 70 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Op> 71 struct transform_variant<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Op, boost::mpl::na> : 72 make_variant_over< 73 typename boost::mpl::transform< 74 typename variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types, 75 Op 76 >::type 77 > 78 {}; 79 80 81 }} // namespace boost::geometry 82 83 84 #endif // BOOST_GEOMETRY_UTIL_TRANSFORM_VARIANT_HPP 85