1 //-----------------------------------------------------------------------------
2 // boost variant/recursive_wrapper_fwd.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
7 // Eric Friedman, Itay Maman
9 // Portions Copyright (C) 2002 David Abrahams
11 // Distributed under the Boost Software License, Version 1.0. (See
12 // accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
16 #define BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
18 #include "boost/mpl/aux_/config/ctps.hpp"
19 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
20 # include "boost/mpl/eval_if.hpp"
21 # include "boost/mpl/bool.hpp"
22 # include "boost/mpl/identity.hpp"
23 # include "boost/type.hpp"
26 #include "boost/mpl/aux_/lambda_support.hpp"
28 // should be the last #include
29 #include "boost/type_traits/detail/bool_trait_def.hpp"
33 //////////////////////////////////////////////////////////////////////////
34 // class template recursive_wrapper
36 // Enables recursive types in templates by breaking cyclic dependencies.
42 // typedef variant< int, recursive_wrapper<my> > var;
49 template <typename T
> class recursive_wrapper
;
51 ///////////////////////////////////////////////////////////////////////////////
52 // metafunction is_recursive_wrapper (modeled on code by David Abrahams)
54 // True iff specified type matches recursive_wrapper<T>.
59 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
62 struct is_recursive_wrapper_impl
68 struct is_recursive_wrapper_impl
< recursive_wrapper
<T
> >
73 #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
75 typedef char (&yes_recursive_wrapper_t
)[1];
76 typedef char (&no_recursive_wrapper_t
)[2];
78 no_recursive_wrapper_t
is_recursive_wrapper_test(...);
81 yes_recursive_wrapper_t
is_recursive_wrapper_test(
82 type
< ::boost::recursive_wrapper
<T
> >
86 struct is_recursive_wrapper_impl
88 BOOST_STATIC_CONSTANT(bool, value
= (
89 sizeof(is_recursive_wrapper_test(type
<T
>()))
90 == sizeof(yes_recursive_wrapper_t
)
94 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
98 BOOST_TT_AUX_BOOL_TRAIT_DEF1(
101 , (::boost::detail::is_recursive_wrapper_impl
<T
>::value
)
104 ///////////////////////////////////////////////////////////////////////////////
105 // metafunction unwrap_recursive
107 // If specified type T matches recursive_wrapper<U>, then U; else T.
110 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
112 template <typename T
>
113 struct unwrap_recursive
117 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,unwrap_recursive
,(T
))
120 template <typename T
>
121 struct unwrap_recursive
< recursive_wrapper
<T
> >
125 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,unwrap_recursive
,(T
))
128 #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
130 template <typename T
>
131 struct unwrap_recursive
133 is_recursive_wrapper
<T
>
138 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,unwrap_recursive
,(T
))
141 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
145 #include "boost/type_traits/detail/bool_trait_undef.hpp"
147 #endif // BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP