1 //-----------------------------------------------------------------------------
2 // boost variant/detail/enable_recursive.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 #ifndef BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_HPP
14 #define BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_HPP
16 #include <boost/variant/detail/enable_recursive_fwd.hpp>
17 #include <boost/variant/variant_fwd.hpp>
19 #if !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
20 # include <boost/mpl/apply.hpp>
21 # include <boost/mpl/eval_if.hpp>
22 # include <boost/mpl/lambda.hpp>
25 #include <boost/variant/detail/substitute.hpp>
26 #include <boost/mpl/aux_/config/ctps.hpp>
27 #include <boost/mpl/bool_fwd.hpp>
28 #include <boost/mpl/if.hpp>
29 #include <boost/mpl/or.hpp>
30 #include <boost/type_traits/is_pointer.hpp>
31 #include <boost/type_traits/is_reference.hpp>
32 #include <boost/type_traits/is_same.hpp>
34 #include <boost/variant/recursive_wrapper.hpp>
37 namespace detail { namespace variant {
39 #if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
41 # define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(T,Dest,Source) \
42 substitute< T , Dest , Source > \
45 #else // defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
47 ///////////////////////////////////////////////////////////////////////////////
48 // (detail) class template rebind1
50 // Limited workaround in case 'substitute' metafunction unavailable.
53 template <typename T, typename U1>
57 typedef typename mpl::lambda<
62 typedef typename mpl::eval_if<
63 is_same< le_, mpl::identity<T> >
65 , mpl::apply1<le_, U1>
69 # define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(T,Dest,Source) \
73 #endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
75 ///////////////////////////////////////////////////////////////////////////////
76 // (detail) metafunction enable_recursive
78 // See boost/variant/detail/enable_recursive_fwd.hpp for more information.
82 template <typename T, typename RecursiveVariant, typename NoWrapper>
83 struct enable_recursive
84 : BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(
85 T, RecursiveVariant, ::boost::recursive_variant_
90 template <typename T, typename RecursiveVariant>
91 struct enable_recursive< T,RecursiveVariant,mpl::false_ >
93 private: // helpers, for metafunction result (below)
95 typedef typename BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(
96 T, RecursiveVariant, ::boost::recursive_variant_
99 public: // metafunction result
101 // [Wrap with recursive_wrapper only if rebind really changed something:]
102 typedef typename mpl::if_<
109 , boost::recursive_wrapper<t_>
115 ///////////////////////////////////////////////////////////////////////////////
116 // (detail) metafunction class quoted_enable_recursive
118 // Same behavior as enable_recursive metafunction (see above).
120 template <typename RecursiveVariant, typename NoWrapper>
121 struct quoted_enable_recursive
123 template <typename T>
125 : enable_recursive<T, RecursiveVariant, NoWrapper>
130 }} // namespace detail::variant
133 #endif // BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_HPP