]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/include/boost/spirit/home/support/detail/as_variant.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / support / detail / as_variant.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7#ifndef BOOST_PP_IS_ITERATING
8#if !defined(BOOST_SPIRIT_AS_VARIANT_NOVEMBER_16_2007_0420PM)
9#define BOOST_SPIRIT_AS_VARIANT_NOVEMBER_16_2007_0420PM
10
11#include <boost/preprocessor/iterate.hpp>
12#include <boost/preprocessor/repetition/enum_params.hpp>
13#include <boost/preprocessor/repetition/enum_binary_params.hpp>
14#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
15#include <boost/preprocessor/repetition/repeat_from_to.hpp>
16#include <boost/variant/variant_fwd.hpp>
17#include <boost/fusion/include/size.hpp>
18#include <boost/fusion/include/begin.hpp>
19#include <boost/fusion/include/next.hpp>
20#include <boost/fusion/include/value_of.hpp>
21#include <boost/mpl/fold.hpp>
22#include <boost/mpl/vector.hpp>
23#include <boost/mpl/push_back.hpp>
24#include <boost/mpl/equal_to.hpp>
25#include <boost/mpl/contains.hpp>
26#include <boost/mpl/limits/list.hpp>
27#include <boost/type_traits/is_same.hpp>
28
29namespace boost { namespace spirit { namespace detail
30{
31 template <int size>
32 struct as_variant_impl;
33
34#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
35#else
36 template <>
37 struct as_variant_impl<0>
38 {
39 template <typename Iterator>
40 struct apply
41 {
42 typedef variant<> type;
43 };
44 };
45#endif
46
47#define BOOST_FUSION_NEXT_ITERATOR(z, n, data) \
48 typedef typename fusion::result_of::next<BOOST_PP_CAT(I, n)>::type \
49 BOOST_PP_CAT(I, BOOST_PP_INC(n));
50
51#define BOOST_FUSION_NEXT_CALL_ITERATOR(z, n, data) \
52 typename gen::BOOST_PP_CAT(I, BOOST_PP_INC(n)) \
53 BOOST_PP_CAT(i, BOOST_PP_INC(n)) = fusion::next(BOOST_PP_CAT(i, n));
54
55#define BOOST_FUSION_VALUE_OF_ITERATOR(z, n, data) \
56 typedef typename fusion::result_of::value_of<BOOST_PP_CAT(I, n)>::type \
57 BOOST_PP_CAT(T, n);
58
59#define BOOST_PP_FILENAME_1 <boost/spirit/home/support/detail/as_variant.hpp>
60
61#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
62#define BOOST_PP_ITERATION_LIMITS (1, BOOST_MPL_LIMIT_LIST_SIZE)
63#else
64#define BOOST_PP_ITERATION_LIMITS (1, BOOST_VARIANT_LIMIT_TYPES)
65#endif
66
67#include BOOST_PP_ITERATE()
68
69#undef BOOST_FUSION_NEXT_ITERATOR
70#undef BOOST_FUSION_NEXT_CALL_ITERATOR
71#undef BOOST_FUSION_VALUE_OF_ITERATOR
72
73 template <typename Sequence>
74 struct as_variant
75 {
76 // build a variant generator being able to generate a variant holding
77 // all of the types as given in the typelist
78 typedef typename
79 detail::as_variant_impl<fusion::result_of::size<Sequence>::value>
80 gen;
81
82 // use this generator to create the actual variant
83 typedef typename gen::template apply<
84 typename fusion::result_of::begin<Sequence>::type
85 >::type
86 type;
87 };
88}}}
89
90#endif
91#else // defined(BOOST_PP_IS_ITERATING)
92///////////////////////////////////////////////////////////////////////////////
93//
94// Preprocessor vertical repetition code
95//
96///////////////////////////////////////////////////////////////////////////////
97
98#define N BOOST_PP_ITERATION()
99
100 template <>
101 struct as_variant_impl<N>
102 {
103 template <typename I0>
104 struct apply
105 {
106 BOOST_PP_REPEAT(N, BOOST_FUSION_NEXT_ITERATOR, _)
107 BOOST_PP_REPEAT(N, BOOST_FUSION_VALUE_OF_ITERATOR, _)
108 typedef variant<BOOST_PP_ENUM_PARAMS(N, T)> type;
109 };
110 };
111
112#undef N
113#endif // defined(BOOST_PP_IS_ITERATING)
114