Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:50

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #ifndef BOOST_PP_IS_ITERATING
0008 #if !defined(BOOST_SPIRIT_AS_VARIANT_NOVEMBER_16_2007_0420PM)
0009 #define BOOST_SPIRIT_AS_VARIANT_NOVEMBER_16_2007_0420PM
0010 
0011 #include <boost/preprocessor/iterate.hpp>
0012 #include <boost/preprocessor/repetition/enum_params.hpp>
0013 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
0014 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
0015 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
0016 #include <boost/variant/variant_fwd.hpp>
0017 #include <boost/fusion/include/size.hpp>
0018 #include <boost/fusion/include/begin.hpp>
0019 #include <boost/fusion/include/next.hpp>
0020 #include <boost/fusion/include/value_of.hpp>
0021 #include <boost/mpl/fold.hpp>
0022 #include <boost/mpl/vector.hpp>
0023 #include <boost/mpl/push_back.hpp>
0024 #include <boost/mpl/equal_to.hpp>
0025 #include <boost/mpl/contains.hpp>
0026 #include <boost/mpl/limits/list.hpp>
0027 #include <boost/type_traits/is_same.hpp>
0028 
0029 namespace boost { namespace spirit { namespace detail
0030 {
0031     template <int size>
0032     struct as_variant_impl;
0033 
0034 #if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
0035 #else
0036     template <>
0037     struct as_variant_impl<0>
0038     {
0039         template <typename Iterator>
0040         struct apply
0041         {
0042             typedef variant<> type;
0043         };
0044     };
0045 #endif
0046 
0047 #define BOOST_FUSION_NEXT_ITERATOR(z, n, data)                                  \
0048     typedef typename fusion::result_of::next<BOOST_PP_CAT(I, n)>::type          \
0049         BOOST_PP_CAT(I, BOOST_PP_INC(n));
0050 
0051 #define BOOST_FUSION_NEXT_CALL_ITERATOR(z, n, data)                             \
0052     typename gen::BOOST_PP_CAT(I, BOOST_PP_INC(n))                              \
0053         BOOST_PP_CAT(i, BOOST_PP_INC(n)) = fusion::next(BOOST_PP_CAT(i, n));
0054 
0055 #define BOOST_FUSION_VALUE_OF_ITERATOR(z, n, data)                              \
0056     typedef typename fusion::result_of::value_of<BOOST_PP_CAT(I, n)>::type      \
0057         BOOST_PP_CAT(T, n);
0058 
0059 #define BOOST_PP_FILENAME_1 <boost/spirit/home/support/detail/as_variant.hpp>
0060 
0061 #if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
0062 #define BOOST_PP_ITERATION_LIMITS (1, BOOST_MPL_LIMIT_LIST_SIZE)
0063 #else
0064 #define BOOST_PP_ITERATION_LIMITS (1, BOOST_VARIANT_LIMIT_TYPES)
0065 #endif
0066 
0067 #include BOOST_PP_ITERATE()
0068 
0069 #undef BOOST_FUSION_NEXT_ITERATOR
0070 #undef BOOST_FUSION_NEXT_CALL_ITERATOR
0071 #undef BOOST_FUSION_VALUE_OF_ITERATOR
0072 
0073     template <typename Sequence>
0074     struct as_variant
0075     {
0076         // build a variant generator being able to generate a variant holding
0077         // all of the types as given in the typelist
0078         typedef typename
0079             detail::as_variant_impl<fusion::result_of::size<Sequence>::value>
0080         gen;
0081 
0082         // use this generator to create the actual variant
0083         typedef typename gen::template apply<
0084                 typename fusion::result_of::begin<Sequence>::type
0085             >::type
0086         type;
0087     };
0088 }}}
0089 
0090 #endif
0091 #else // defined(BOOST_PP_IS_ITERATING)
0092 ///////////////////////////////////////////////////////////////////////////////
0093 //
0094 //  Preprocessor vertical repetition code
0095 //
0096 ///////////////////////////////////////////////////////////////////////////////
0097 
0098 #define N BOOST_PP_ITERATION()
0099 
0100     template <>
0101     struct as_variant_impl<N>
0102     {
0103         template <typename I0>
0104         struct apply
0105         {
0106             BOOST_PP_REPEAT(N, BOOST_FUSION_NEXT_ITERATOR, _)
0107             BOOST_PP_REPEAT(N, BOOST_FUSION_VALUE_OF_ITERATOR, _)
0108             typedef variant<BOOST_PP_ENUM_PARAMS(N, T)> type;
0109         };
0110     };
0111 
0112 #undef N
0113 #endif // defined(BOOST_PP_IS_ITERATING)
0114