epoc32/include/stdapis/boost/variant/recursive_wrapper_fwd.hpp
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 //-----------------------------------------------------------------------------
     2 // boost variant/recursive_wrapper_fwd.hpp header file
     3 // See http://www.boost.org for updates, documentation, and revision history.
     4 //-----------------------------------------------------------------------------
     5 //
     6 // Copyright (c) 2002
     7 // Eric Friedman, Itay Maman
     8 //
     9 // Portions Copyright (C) 2002 David Abrahams
    10 //
    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)
    14 
    15 #ifndef BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
    16 #define BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
    17 
    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"
    24 #endif
    25 
    26 #include "boost/mpl/aux_/lambda_support.hpp"
    27 
    28 // should be the last #include
    29 #include "boost/type_traits/detail/bool_trait_def.hpp"
    30 
    31 namespace boost {
    32 
    33 //////////////////////////////////////////////////////////////////////////
    34 // class template recursive_wrapper
    35 //
    36 // Enables recursive types in templates by breaking cyclic dependencies.
    37 //
    38 // For example:
    39 //
    40 //   class my;
    41 //
    42 //   typedef variant< int, recursive_wrapper<my> > var;
    43 //
    44 //   class my {
    45 //     var var_;
    46 //     ...
    47 //   };
    48 //
    49 template <typename T> class recursive_wrapper;
    50 
    51 ///////////////////////////////////////////////////////////////////////////////
    52 // metafunction is_recursive_wrapper (modeled on code by David Abrahams)
    53 //
    54 // True iff specified type matches recursive_wrapper<T>.
    55 //
    56 
    57 namespace detail {
    58 
    59 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
    60 
    61 template <typename T>
    62 struct is_recursive_wrapper_impl
    63     : mpl::false_
    64 {
    65 };
    66 
    67 template <typename T>
    68 struct is_recursive_wrapper_impl< recursive_wrapper<T> >
    69     : mpl::true_
    70 {
    71 };
    72 
    73 #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
    74 
    75 typedef char (&yes_recursive_wrapper_t)[1];
    76 typedef char (&no_recursive_wrapper_t)[2];
    77 
    78 no_recursive_wrapper_t is_recursive_wrapper_test(...);
    79 
    80 template<typename T>
    81 yes_recursive_wrapper_t is_recursive_wrapper_test(
    82       type< ::boost::recursive_wrapper<T> >
    83     );
    84 
    85 template<typename T>
    86 struct is_recursive_wrapper_impl
    87 {
    88     BOOST_STATIC_CONSTANT(bool, value = (
    89           sizeof(is_recursive_wrapper_test(type<T>()))
    90           == sizeof(yes_recursive_wrapper_t)
    91         ));
    92 };
    93 
    94 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
    95 
    96 } // namespace detail
    97 
    98 BOOST_TT_AUX_BOOL_TRAIT_DEF1(
    99       is_recursive_wrapper
   100     , T
   101     , (::boost::detail::is_recursive_wrapper_impl<T>::value)
   102     )
   103 
   104 ///////////////////////////////////////////////////////////////////////////////
   105 // metafunction unwrap_recursive
   106 //
   107 // If specified type T matches recursive_wrapper<U>, then U; else T.
   108 //
   109 
   110 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
   111 
   112 template <typename T>
   113 struct unwrap_recursive
   114 {
   115     typedef T type;
   116 
   117     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,unwrap_recursive,(T))
   118 };
   119 
   120 template <typename T>
   121 struct unwrap_recursive< recursive_wrapper<T> >
   122 {
   123     typedef T type;
   124 
   125     BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,unwrap_recursive,(T))
   126 };
   127 
   128 #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
   129 
   130 template <typename T>
   131 struct unwrap_recursive
   132     : mpl::eval_if<
   133           is_recursive_wrapper<T>
   134         , T
   135         , mpl::identity< T >
   136         >
   137 {
   138     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,unwrap_recursive,(T))
   139 };
   140 
   141 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
   142 
   143 } // namespace boost
   144 
   145 #include "boost/type_traits/detail/bool_trait_undef.hpp"
   146 
   147 #endif // BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP