Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:02:10

0001 //-----------------------------------------------------------------------------
0002 // boost variant/recursive_variant.hpp header file
0003 // See http://www.boost.org for updates, documentation, and revision history.
0004 //-----------------------------------------------------------------------------
0005 //
0006 // Copyright (c) 2003 Eric Friedman
0007 // Copyright (c) 2013-2023 Antony Polukhin
0008 //
0009 // Distributed under the Boost Software License, Version 1.0. (See
0010 // accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 #ifndef BOOST_VARIANT_RECURSIVE_VARIANT_HPP
0014 #define BOOST_VARIANT_RECURSIVE_VARIANT_HPP
0015 
0016 #include <boost/variant/variant_fwd.hpp>
0017 #include <boost/variant/detail/enable_recursive.hpp>
0018 #include <boost/variant/detail/substitute_fwd.hpp>
0019 #include <boost/variant/detail/make_variant_list.hpp>
0020 #include <boost/variant/detail/over_sequence.hpp>
0021 
0022 #include <boost/mpl/aux_/lambda_arity_param.hpp>
0023 
0024 #include <boost/mpl/equal.hpp>
0025 #include <boost/mpl/eval_if.hpp>
0026 #include <boost/mpl/identity.hpp>
0027 #include <boost/mpl/if.hpp>
0028 #include <boost/mpl/protect.hpp>
0029 #include <boost/mpl/transform.hpp>
0030 #include <boost/type_traits/is_same.hpp>
0031 #include <boost/preprocessor/cat.hpp>
0032 #include <boost/preprocessor/repeat.hpp>
0033 
0034 #include <boost/mpl/bool.hpp>
0035 #include <boost/mpl/is_sequence.hpp>
0036 #include <boost/variant/variant.hpp>
0037 
0038 namespace boost {
0039 
0040 namespace detail { namespace variant {
0041 
0042 ///////////////////////////////////////////////////////////////////////////////
0043 // (detail) metafunction specialization substitute
0044 //
0045 // Handles embedded variant types when substituting for recursive_variant_.
0046 //
0047 
0048 template <
0049       BOOST_VARIANT_ENUM_PARAMS(typename T)
0050     , typename RecursiveVariant
0051       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
0052     >
0053 struct substitute<
0054       ::boost::variant<
0055           recursive_flag< T0 >
0056         , BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
0057         >
0058     , RecursiveVariant
0059     , ::boost::recursive_variant_
0060       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
0061     >
0062 {
0063     typedef ::boost::variant<
0064           recursive_flag< T0 >
0065         , BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
0066         > type;
0067 };
0068 
0069 template <
0070       BOOST_VARIANT_ENUM_PARAMS(typename T)
0071     , typename RecursiveVariant
0072       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
0073     >
0074 struct substitute<
0075       ::boost::variant<
0076           ::boost::detail::variant::over_sequence< T0 >
0077         , BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
0078         >
0079     , RecursiveVariant
0080     , ::boost::recursive_variant_
0081       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
0082     >
0083 {
0084 private:
0085 
0086     typedef T0 initial_types;
0087 
0088     typedef typename mpl::transform<
0089           initial_types
0090         , mpl::protect< quoted_enable_recursive<RecursiveVariant,mpl::true_> >
0091         >::type types;
0092 
0093 public:
0094 
0095     typedef typename mpl::if_<
0096           mpl::equal<initial_types, types, ::boost::is_same<mpl::_1, mpl::_2> >
0097         , ::boost::variant<
0098               ::boost::detail::variant::over_sequence< T0 >
0099             , BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
0100             >
0101         , ::boost::variant< over_sequence<types> >
0102         >::type type;
0103 };
0104 
0105 template <
0106       BOOST_VARIANT_ENUM_PARAMS(typename T)
0107     , typename RecursiveVariant
0108       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
0109     >
0110 struct substitute<
0111       ::boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >
0112     , RecursiveVariant
0113     , ::boost::recursive_variant_
0114       BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
0115     >
0116 {   
0117     typedef ::boost::variant<
0118         typename enable_recursive<   
0119               T0              
0120             , RecursiveVariant               
0121             , mpl::true_                     
0122         >::type,
0123         typename enable_recursive<   
0124               TN              
0125             , RecursiveVariant               
0126             , mpl::true_                     
0127         >::type...  
0128     > type;
0129 };
0130 
0131 }} // namespace detail::variant
0132 
0133 ///////////////////////////////////////////////////////////////////////////////
0134 // metafunction make_recursive_variant
0135 //
0136 // See docs and boost/variant/variant_fwd.hpp for more information.
0137 //
0138 template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
0139 struct make_recursive_variant
0140 {
0141 public: // metafunction result
0142 
0143     typedef boost::variant<
0144           detail::variant::recursive_flag< T0 >
0145         , BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
0146         > type;
0147 
0148 };
0149 
0150 ///////////////////////////////////////////////////////////////////////////////
0151 // metafunction make_recursive_variant_over
0152 //
0153 // See docs and boost/variant/variant_fwd.hpp for more information.
0154 //
0155 template <typename Types>
0156 struct make_recursive_variant_over
0157 {
0158 private: // precondition assertions
0159 
0160     BOOST_STATIC_ASSERT(( ::boost::mpl::is_sequence<Types>::value ));
0161 
0162 public: // metafunction result
0163 
0164     typedef typename make_recursive_variant<
0165           detail::variant::over_sequence< Types >
0166         >::type type;
0167 
0168 };
0169 
0170 } // namespace boost
0171 
0172 #endif // BOOST_VARIANT_RECURSIVE_VARIANT_HPP