Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:33

0001 //-----------------------------------------------------------------------------
0002 // boost variant/recursive_wrapper_fwd.hpp header file
0003 // See http://www.boost.org for updates, documentation, and revision history.
0004 //-----------------------------------------------------------------------------
0005 //
0006 // Copyright (c) 2002 Eric Friedman, Itay Maman
0007 // Copyright (c) 2016-2023 Antony Polukhin
0008 //
0009 // Portions Copyright (C) 2002 David Abrahams
0010 //
0011 // Distributed under the Boost Software License, Version 1.0. (See
0012 // accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
0014 
0015 #ifndef BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
0016 #define BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
0017 
0018 #include <boost/mpl/bool.hpp>
0019 #include <boost/mpl/aux_/config/ctps.hpp>
0020 #include <boost/mpl/aux_/lambda_support.hpp>
0021 #include <boost/type_traits/integral_constant.hpp>
0022 #include <boost/type_traits/is_constructible.hpp>
0023 #include <boost/type_traits/is_nothrow_move_constructible.hpp>
0024 
0025 namespace boost {
0026 
0027 //////////////////////////////////////////////////////////////////////////
0028 // class template recursive_wrapper
0029 //
0030 // Enables recursive types in templates by breaking cyclic dependencies.
0031 //
0032 // For example:
0033 //
0034 //   class my;
0035 //
0036 //   typedef variant< int, recursive_wrapper<my> > var;
0037 //
0038 //   class my {
0039 //     var var_;
0040 //     ...
0041 //   };
0042 //
0043 template <typename T> class recursive_wrapper;
0044 
0045 
0046 ///////////////////////////////////////////////////////////////////////////////
0047 // metafunction is_constructible partial specializations.
0048 //
0049 // recursive_wrapper<T> is constructible only from T and recursive_wrapper<T>.
0050 //
0051 template <class T>          struct is_constructible<recursive_wrapper<T>, T>                            : boost::true_type{};
0052 template <class T>          struct is_constructible<recursive_wrapper<T>, const T>                      : boost::true_type{};
0053 template <class T>          struct is_constructible<recursive_wrapper<T>, T&>                           : boost::true_type{};
0054 template <class T>          struct is_constructible<recursive_wrapper<T>, const T&>                     : boost::true_type{};
0055 template <class T>          struct is_constructible<recursive_wrapper<T>, recursive_wrapper<T> >        : boost::true_type{};
0056 template <class T>          struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<T> >  : boost::true_type{};
0057 template <class T>          struct is_constructible<recursive_wrapper<T>, recursive_wrapper<T>& >       : boost::true_type{};
0058 template <class T>          struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<T>& > : boost::true_type{};
0059 
0060 template <class T, class U> struct is_constructible<recursive_wrapper<T>, U >                           : boost::false_type{};
0061 template <class T, class U> struct is_constructible<recursive_wrapper<T>, const U >                     : boost::false_type{};
0062 template <class T, class U> struct is_constructible<recursive_wrapper<T>, U& >                          : boost::false_type{};
0063 template <class T, class U> struct is_constructible<recursive_wrapper<T>, const U& >                    : boost::false_type{};
0064 template <class T, class U> struct is_constructible<recursive_wrapper<T>, recursive_wrapper<U> >        : boost::false_type{};
0065 template <class T, class U> struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<U> >  : boost::false_type{};
0066 template <class T, class U> struct is_constructible<recursive_wrapper<T>, recursive_wrapper<U>& >       : boost::false_type{};
0067 template <class T, class U> struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<U>& > : boost::false_type{};
0068 
0069 // recursive_wrapper is not nothrow move constructible, because it's constructor does dynamic memory allocation.
0070 // This specialisation is required to workaround GCC6 issue: https://svn.boost.org/trac/boost/ticket/12680
0071 template <class T> struct is_nothrow_move_constructible<recursive_wrapper<T> > : boost::false_type{};
0072 
0073 ///////////////////////////////////////////////////////////////////////////////
0074 // metafunction is_recursive_wrapper (modeled on code by David Abrahams)
0075 //
0076 // True if specified type matches recursive_wrapper<T>.
0077 //
0078 
0079 namespace detail {
0080 
0081 
0082 template <typename T>
0083 struct is_recursive_wrapper_impl
0084     : mpl::false_
0085 {
0086 };
0087 
0088 template <typename T>
0089 struct is_recursive_wrapper_impl< recursive_wrapper<T> >
0090     : mpl::true_
0091 {
0092 };
0093 
0094 
0095 } // namespace detail
0096 
0097 template< typename T > struct is_recursive_wrapper
0098     : public ::boost::integral_constant<bool,(::boost::detail::is_recursive_wrapper_impl<T>::value)>
0099 {
0100 public:
0101     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_recursive_wrapper,(T))
0102 };
0103 
0104 ///////////////////////////////////////////////////////////////////////////////
0105 // metafunction unwrap_recursive
0106 //
0107 // If specified type T matches recursive_wrapper<U>, then U; else T.
0108 //
0109 
0110 
0111 template <typename T>
0112 struct unwrap_recursive
0113 {
0114     typedef T type;
0115 
0116     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,unwrap_recursive,(T))
0117 };
0118 
0119 template <typename T>
0120 struct unwrap_recursive< recursive_wrapper<T> >
0121 {
0122     typedef T type;
0123 
0124     BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,unwrap_recursive,(T))
0125 };
0126 
0127 
0128 } // namespace boost
0129 
0130 #endif // BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP