Ticket #9238: spirit-variant-variadic.patch

File spirit-variant-variadic.patch, 4.7 KB (added by Mario Lang <mlang@…>, 9 years ago)

Complete BOOST_VARIANT_USE_VARIADIC_TEMPLATES support for Spirit

  • boost/spirit/home/qi/detail/pass_container.hpp

     
    198198    // We pass through the container attribute if at least one of the embedded
    199199    // types in the variant requires to pass through the attribute
    200200
     201#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(BOOST_VARIANT_USE_VARIADIC_TEMPLATES)
     202    template <typename Container, typename ValueType, typename Sequence
     203      , typename T>
     204    struct pass_through_container<Container, ValueType, boost::variant<T>, Sequence>
     205      : pass_through_container<Container, ValueType, T, Sequence>
     206    {};
     207
     208    template <typename Container, typename ValueType, typename Sequence
     209      , BOOST_VARIANT_ENUM_PARAMS(typename T)>
     210    struct pass_through_container<Container, ValueType
     211          , boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Sequence>
     212      : mpl::bool_<pass_through_container<Container, ValueType, T0, Sequence>::type::value ||
     213                   pass_through_container<Container, ValueType, boost::variant<TN...>, Sequence>::type::value>
     214    {};
     215#else
    201216#define BOOST_SPIRIT_PASS_THROUGH_CONTAINER(z, N, _)                          \
    202217    pass_through_container<Container, ValueType,                              \
    203218        BOOST_PP_CAT(T, N), Sequence>::type::value ||                         \
     
    219234    {};
    220235
    221236#undef BOOST_SPIRIT_PASS_THROUGH_CONTAINER
     237#endif
    222238}}}}
    223239
    224240///////////////////////////////////////////////////////////////////////////////
  • boost/spirit/home/support/attributes.hpp

     
    202202    struct is_weak_substitute<T, optional<Expected> >
    203203      : is_weak_substitute<T, Expected> {};
    204204
     205#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(BOOST_VARIANT_USE_VARIADIC_TEMPLATES)
     206    template <typename T, typename Expected>
     207    struct is_weak_substitute<boost::variant<T>, Expected>
     208      : is_weak_substitute<T, Expected>
     209    {};
     210
     211    template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Expected>
     212    struct is_weak_substitute<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
     213                              Expected>
     214      : mpl::bool_<is_weak_substitute<T0, Expected>::type::value &&
     215                   is_weak_substitute<boost::variant<TN...>, Expected>::type::value>
     216    {};
     217#else
    205218#define BOOST_SPIRIT_IS_WEAK_SUBSTITUTE(z, N, _)                              \
    206219    is_weak_substitute<BOOST_PP_CAT(T, N), Expected>::type::value &&          \
    207220    /***/
     
    220233    {};
    221234
    222235#undef BOOST_SPIRIT_IS_WEAK_SUBSTITUTE
     236#endif
    223237
    224238    template <typename T>
    225239    struct is_weak_substitute<T, T
  • boost/spirit/home/support/container.hpp

     
    5959      : is_container<T>
    6060    {};
    6161
     62#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(BOOST_VARIANT_USE_VARIADIC_TEMPLATES)
     63    template<typename T>
     64    struct is_container< boost::variant<T> >
     65      : is_container<T>
     66    {};
     67
     68    template<BOOST_VARIANT_ENUM_PARAMS(typename T)>
     69    struct is_container< boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
     70      : mpl::bool_<is_container<T0>::value ||
     71                   is_container< boost::variant<TN...> >::value> {};
     72
     73#else
    6274#define BOOST_SPIRIT_IS_CONTAINER(z, N, data)                                 \
    6375        is_container<BOOST_PP_CAT(T, N)>::value ||                            \
    6476    /***/
     
    7688    {};
    7789
    7890#undef BOOST_SPIRIT_IS_CONTAINER
     91#endif
    7992
    8093    template <typename T, typename Enable/* = void*/>
    8194    struct is_iterator_range
  • boost/spirit/home/support/detail/as_variant.hpp

     
    3030    template <int size>
    3131    struct as_variant_impl;
    3232
     33#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(BOOST_VARIANT_USE_VARIADIC_TEMPLATES)
     34#else
    3335    template <>
    3436    struct as_variant_impl<0>
    3537    {
     
    3941            typedef variant<> type;
    4042        };
    4143    };
     44#endif
    4245
    4346#define BOOST_FUSION_NEXT_ITERATOR(z, n, data)                                  \
    4447    typedef typename fusion::result_of::next<BOOST_PP_CAT(I, n)>::type          \