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