Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:32:52

0001 // Boost.TypeErasure library
0002 //
0003 // Copyright 2011 Steven Watanabe
0004 //
0005 // Distributed under the Boost Software License Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // $Id$
0010 
0011 #ifndef BOOST_TYPE_ERASURE_ANY_HPP_INCLUDED
0012 #define BOOST_TYPE_ERASURE_ANY_HPP_INCLUDED
0013 
0014 #include <algorithm>
0015 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0016 #   include <utility>  // std::forward, std::move
0017 #endif
0018 #include <boost/config.hpp>
0019 #include <boost/utility/enable_if.hpp>
0020 #include <boost/utility/addressof.hpp>
0021 #include <boost/utility/declval.hpp>
0022 #include <boost/mpl/bool.hpp>
0023 #include <boost/mpl/or.hpp>
0024 #include <boost/mpl/pair.hpp>
0025 #include <boost/mpl/map.hpp>
0026 #include <boost/mpl/reverse_fold.hpp>
0027 #include <boost/type_traits/decay.hpp>
0028 #include <boost/type_traits/remove_reference.hpp>
0029 #include <boost/type_traits/remove_const.hpp>
0030 #include <boost/type_traits/is_same.hpp>
0031 #include <boost/type_traits/is_const.hpp>
0032 #include <boost/preprocessor/cat.hpp>
0033 #include <boost/preprocessor/iteration/iterate.hpp>
0034 #include <boost/preprocessor/repetition/enum_params.hpp>
0035 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
0036 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0037 #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
0038 #include <boost/type_erasure/detail/access.hpp>
0039 #include <boost/type_erasure/detail/any_base.hpp>
0040 #include <boost/type_erasure/detail/normalize.hpp>
0041 #include <boost/type_erasure/detail/storage.hpp>
0042 #include <boost/type_erasure/detail/instantiate.hpp>
0043 #include <boost/type_erasure/config.hpp>
0044 #include <boost/type_erasure/binding.hpp>
0045 #include <boost/type_erasure/static_binding.hpp>
0046 #include <boost/type_erasure/concept_interface.hpp>
0047 #include <boost/type_erasure/call.hpp>
0048 #include <boost/type_erasure/relaxed.hpp>
0049 #include <boost/type_erasure/param.hpp>
0050 
0051 #ifdef BOOST_MSVC
0052 #pragma warning(push)
0053 #pragma warning(disable:4355)
0054 #pragma warning(disable:4521)
0055 #pragma warning(disable:4522) // multiple assignment operators specified
0056 #endif
0057 
0058 namespace boost {
0059 namespace type_erasure {
0060 
0061 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
0062 
0063 template<class Sig>
0064 struct constructible;
0065 
0066 template<class T>
0067 struct destructible;
0068 
0069 template<class T, class U>
0070 struct assignable;
0071 
0072 #endif
0073 
0074 namespace detail {
0075 
0076 #if defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
0077 
0078 template<class Concept, class Base, class ID>
0079 struct choose_concept_interface
0080 {
0081     typedef ::boost::type_erasure::concept_interface<Concept, Base, ID> type;
0082 };
0083 
0084 #else
0085 
0086 struct default_concept_interface
0087 {
0088     template<class Concept, class Base, class ID>
0089     using apply = ::boost::type_erasure::concept_interface<Concept, Base, ID>;
0090 };
0091 
0092 default_concept_interface boost_type_erasure_find_interface(...);
0093 
0094 template<class Concept, class Base, class ID>
0095 struct choose_concept_interface
0096 {
0097     typedef decltype(boost_type_erasure_find_interface(::boost::declval<Concept>())) finder;
0098     typedef typename finder::template apply<Concept, Base, ID> type;
0099 };
0100 
0101 #endif
0102 
0103 #ifndef BOOST_TYPE_ERASURE_USE_MP11
0104 
0105 template<class Derived, class Concept, class T>
0106 struct compute_bases
0107 {
0108     typedef typename ::boost::mpl::reverse_fold<
0109         typename ::boost::type_erasure::detail::collect_concepts<
0110             Concept
0111         >::type,
0112         ::boost::type_erasure::any_base<Derived>,
0113         ::boost::type_erasure::detail::choose_concept_interface<
0114             ::boost::mpl::_2,
0115             ::boost::mpl::_1,
0116             T
0117         >
0118     >::type type;
0119 };
0120 
0121 #else
0122 
0123 template<class ID>
0124 struct compute_bases_f
0125 {
0126     template<class Concept, class Base>
0127     using apply = typename ::boost::type_erasure::detail::choose_concept_interface<Concept, Base, ID>::type;
0128 };
0129 
0130 template<class Derived, class Concept, class T>
0131 using compute_bases_t =
0132     ::boost::mp11::mp_reverse_fold<
0133         typename ::boost::type_erasure::detail::collect_concepts_t<
0134             Concept
0135         >,
0136         ::boost::type_erasure::any_base<Derived>,
0137         ::boost::type_erasure::detail::compute_bases_f<T>::template apply
0138     >;
0139 
0140 template<class Derived, class Concept, class T>
0141 using compute_bases = ::boost::mpl::identity< ::boost::type_erasure::detail::compute_bases_t<Derived, Concept, T> >;
0142 
0143 #endif
0144 
0145 template<class T>
0146 T make(T*) { return T(); }
0147 
0148 // This dance is necessary to avoid errors calling
0149 // an ellipsis function with a non-trivially-copyable
0150 // argument.
0151 
0152 typedef char no;
0153 struct yes { no dummy[2]; };
0154 
0155 template<class Op>
0156 yes check_overload(const Op*);
0157 no check_overload(const void*);
0158 
0159 struct fallback {};
0160 
0161 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0162 
0163 template<class T>
0164 fallback make_fallback(T&&, boost::mpl::false_)
0165 {
0166     return fallback();
0167 }
0168 
0169 template<class T>
0170 T&& make_fallback(T&& arg, boost::mpl::true_)
0171 {
0172     return std::forward<T>(arg);
0173 }
0174 
0175 #else
0176 
0177 template<class T>
0178 fallback make_fallback(const T&, boost::mpl::false_)
0179 {
0180     return fallback();
0181 }
0182 
0183 template<class T>
0184 const T& make_fallback(const T& arg, boost::mpl::true_)
0185 {
0186     return arg;
0187 }
0188 
0189 #endif
0190 
0191 template<class T>
0192 struct is_any : ::boost::mpl::false_ {};
0193 
0194 template<class Concept, class T>
0195 struct is_any<any<Concept, T> > : ::boost::mpl::true_ {};
0196 
0197 #ifdef BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS
0198 
0199 template<class Any, class... U>
0200 struct has_constructor :
0201     ::boost::mpl::bool_<
0202         sizeof(
0203             ::boost::type_erasure::detail::check_overload(
0204                 ::boost::declval<Any&>().
0205                     _boost_type_erasure_deduce_constructor(::boost::declval<U>()...)
0206             )
0207         ) == sizeof(::boost::type_erasure::detail::yes)
0208     >
0209 {};
0210 
0211 template<class Any>
0212 using has_copy_constructor =
0213     ::boost::type_erasure::is_subconcept<
0214         ::boost::type_erasure::constructible<
0215             typename ::boost::type_erasure::placeholder_of<Any>::type(typename ::boost::type_erasure::placeholder_of<Any>::type const&)
0216         >,
0217         typename ::boost::type_erasure::concept_of<Any>::type
0218     >;
0219 
0220 template<class Any>
0221 using has_move_constructor =
0222     ::boost::type_erasure::is_subconcept<
0223         ::boost::type_erasure::constructible<
0224             typename ::boost::type_erasure::placeholder_of<Any>::type(typename ::boost::type_erasure::placeholder_of<Any>::type &&)
0225         >,
0226         typename ::boost::type_erasure::concept_of<Any>::type
0227     >;
0228 
0229 template<class Any>
0230 using has_mutable_copy_constructor =
0231     ::boost::type_erasure::is_subconcept<
0232         ::boost::type_erasure::constructible<
0233             typename ::boost::type_erasure::placeholder_of<Any>::type(typename ::boost::type_erasure::placeholder_of<Any>::type &)
0234         >,
0235         typename ::boost::type_erasure::concept_of<Any>::type
0236     >;
0237 
0238 struct empty {};
0239 
0240 template<class T>
0241 struct is_binding_arg : ::boost::mpl::false_ {};
0242 template<class T>
0243 struct is_binding_arg<binding<T> > : ::boost::mpl::true_ {};
0244 template<class T>
0245 struct is_binding_arg<binding<T>&&> : ::boost::mpl::true_ {};
0246 template<class T>
0247 struct is_binding_arg<binding<T>&> : ::boost::mpl::true_ {};
0248 template<class T>
0249 struct is_binding_arg<binding<T> const&> : ::boost::mpl::true_ {};
0250 
0251 template<class T>
0252 struct is_static_binding_arg : ::boost::mpl::false_ {};
0253 template<class T>
0254 struct is_static_binding_arg<static_binding<T> > : ::boost::mpl::true_ {};
0255 template<class T>
0256 struct is_static_binding_arg<static_binding<T>&&> : ::boost::mpl::true_ {};
0257 template<class T>
0258 struct is_static_binding_arg<static_binding<T>&> : ::boost::mpl::true_ {};
0259 template<class T>
0260 struct is_static_binding_arg<static_binding<T> const&> : ::boost::mpl::true_ {};
0261 
0262 template<class T>
0263 struct is_any_arg : ::boost::mpl::false_ {};
0264 template<class Concept, class T>
0265 struct is_any_arg<any<Concept, T> > : ::boost::mpl::true_ {};
0266 template<class Concept, class T>
0267 struct is_any_arg<any<Concept, T>&&> : ::boost::mpl::true_ {};
0268 template<class Concept, class T>
0269 struct is_any_arg<any<Concept, T>&> : ::boost::mpl::true_ {};
0270 template<class Concept, class T>
0271 struct is_any_arg<any<Concept, T> const&> : ::boost::mpl::true_ {};
0272 
0273 template<class T>
0274 struct safe_concept_of;
0275 template<class Concept, class T>
0276 struct safe_concept_of<any<Concept, T> > { typedef Concept type; };
0277 template<class Concept, class T>
0278 struct safe_concept_of<any<Concept, T>&&> { typedef Concept type; };
0279 template<class Concept, class T>
0280 struct safe_concept_of<any<Concept, T>&> { typedef Concept type; };
0281 template<class Concept, class T>
0282 struct safe_concept_of<any<Concept, T> const&> { typedef Concept type; };
0283 
0284 template<class T>
0285 struct safe_placeholder_of;
0286 template<class Concept, class T>
0287 struct safe_placeholder_of<any<Concept, T> > { typedef T type; };
0288 template<class Concept, class T>
0289 struct safe_placeholder_of<any<Concept, T>&&> { typedef T type; };
0290 template<class Concept, class T>
0291 struct safe_placeholder_of<any<Concept, T>&> { typedef T type; };
0292 template<class Concept, class T>
0293 struct safe_placeholder_of<any<Concept, T> const&> { typedef T type; };
0294 
0295 template<class T>
0296 using safe_placeholder_t = ::boost::remove_cv_t< ::boost::remove_reference_t<typename safe_placeholder_of<T>::type> >;
0297 
0298 }
0299 
0300 // Enables or deletes the copy/move constructors depending on the Concept.
0301 template<class Base, class Enable = void>
0302 struct any_constructor_control : Base
0303 {
0304     using Base::Base;
0305 };
0306 
0307 template<class Base>
0308 struct any_constructor_control<
0309     Base,
0310     typename boost::enable_if_c<
0311         !::boost::type_erasure::detail::has_copy_constructor<Base>::value &&
0312         ::boost::type_erasure::detail::has_move_constructor<Base>::value &&
0313         ::boost::type_erasure::detail::has_mutable_copy_constructor<Base>::value
0314     >::type
0315 > : Base
0316 {
0317     using Base::Base;
0318     any_constructor_control() = default;
0319     any_constructor_control(any_constructor_control&) = default;
0320     any_constructor_control(any_constructor_control&&) = default;
0321     any_constructor_control& operator=(any_constructor_control const& other) { static_cast<Base&>(*this) = static_cast<Base const&>(other); return *this; }
0322     any_constructor_control& operator=(any_constructor_control & other) { static_cast<Base&>(*this) = static_cast<Base&>(other); return *this; }
0323     any_constructor_control& operator=(any_constructor_control &&) = default;
0324 };
0325 
0326 template<class Base>
0327 struct any_constructor_control<
0328     Base,
0329     typename boost::enable_if_c<
0330         !::boost::type_erasure::detail::has_copy_constructor<Base>::value &&
0331         !::boost::type_erasure::detail::has_move_constructor<Base>::value &&
0332         ::boost::type_erasure::detail::has_mutable_copy_constructor<Base>::value
0333     >::type
0334 > : Base
0335 {
0336     using Base::Base;
0337     any_constructor_control() = default;
0338     any_constructor_control(any_constructor_control&) = default;
0339     any_constructor_control(any_constructor_control&&) = delete;
0340     any_constructor_control& operator=(any_constructor_control const& other) { static_cast<Base&>(*this) = static_cast<Base const&>(other); return *this; }
0341     any_constructor_control& operator=(any_constructor_control & other) { static_cast<Base&>(*this) = static_cast<Base&>(other); return *this; }
0342     any_constructor_control& operator=(any_constructor_control &&) = default;
0343 };
0344 
0345 template<class Base>
0346 struct any_constructor_control<
0347     Base,
0348     typename boost::enable_if_c<
0349         !::boost::type_erasure::detail::has_copy_constructor<Base>::value &&
0350         ::boost::type_erasure::detail::has_move_constructor<Base>::value &&
0351         !::boost::type_erasure::detail::has_mutable_copy_constructor<Base>::value
0352     >::type
0353 > : Base
0354 {
0355     using Base::Base;
0356     any_constructor_control() = default;
0357     any_constructor_control(any_constructor_control const&) = delete;
0358     any_constructor_control(any_constructor_control&&) = default;
0359     any_constructor_control& operator=(any_constructor_control const& other) { static_cast<Base&>(*this) = static_cast<Base const&>(other); return *this; }
0360     any_constructor_control& operator=(any_constructor_control & other) { static_cast<Base&>(*this) = static_cast<Base&>(other); return *this; }
0361     any_constructor_control& operator=(any_constructor_control &&) = default;
0362 };
0363 
0364 template<class Base>
0365 struct any_constructor_control<
0366     Base,
0367     typename boost::enable_if_c<
0368         !::boost::type_erasure::detail::has_copy_constructor<Base>::value &&
0369         !::boost::type_erasure::detail::has_move_constructor<Base>::value &&
0370         !::boost::type_erasure::detail::has_mutable_copy_constructor<Base>::value
0371     >::type
0372 > : Base
0373 {
0374     using Base::Base;
0375     any_constructor_control() = default;
0376     any_constructor_control(any_constructor_control const&) = delete;
0377     any_constructor_control(any_constructor_control&&) = delete;
0378     any_constructor_control& operator=(any_constructor_control const& other) { static_cast<Base&>(*this) = static_cast<Base const&>(other); return *this; }
0379     any_constructor_control& operator=(any_constructor_control & other) { static_cast<Base&>(*this) = static_cast<Base&>(other); return *this; }
0380     any_constructor_control& operator=(any_constructor_control &&) = default;
0381 };
0382 
0383 template<class Concept, class T>
0384 struct any_constructor_impl :
0385     ::boost::type_erasure::detail::compute_bases<
0386         ::boost::type_erasure::any<Concept, T>,
0387         Concept,
0388         T
0389     >::type
0390 {
0391     typedef typename ::boost::type_erasure::detail::compute_bases<
0392         ::boost::type_erasure::any<Concept, T>,
0393         Concept,
0394         T
0395     >::type _boost_type_erasure_base;
0396     // Internal constructors
0397     typedef ::boost::type_erasure::binding<Concept> _boost_type_erasure_table_type;
0398     any_constructor_impl(const ::boost::type_erasure::detail::storage& data_arg, const _boost_type_erasure_table_type& table_arg)
0399       : _boost_type_erasure_table(table_arg),
0400         _boost_type_erasure_data(data_arg)
0401     {}
0402     any_constructor_impl(::boost::type_erasure::detail::storage&& data_arg, const _boost_type_erasure_table_type& table_arg)
0403       : _boost_type_erasure_table(table_arg),
0404         _boost_type_erasure_data(data_arg)
0405     {}
0406     // default constructor
0407     any_constructor_impl()
0408     {
0409         BOOST_MPL_ASSERT((::boost::type_erasure::is_relaxed<Concept>));
0410         _boost_type_erasure_data.data = 0;
0411     }
0412     // capturing constructor
0413     template<class U,
0414         typename ::boost::enable_if_c<
0415             !::boost::type_erasure::detail::is_any_arg<U>::value &&
0416             !::boost::type_erasure::detail::is_binding_arg<U>::value &&
0417             !::boost::type_erasure::detail::is_static_binding_arg<U>::value
0418         >::type* = nullptr
0419     >
0420     any_constructor_impl(U&& data_arg)
0421       : _boost_type_erasure_table((
0422             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, ::boost::decay_t<U>),
0423             ::boost::type_erasure::make_binding<
0424                 ::boost::mpl::map1< ::boost::mpl::pair<T, ::boost::decay_t<U> > >
0425             >()
0426         )),
0427         _boost_type_erasure_data(std::forward<U>(data_arg))
0428     {}
0429     template<class U, class Map,
0430         typename ::boost::enable_if_c<
0431             !::boost::type_erasure::detail::is_any_arg<U>::value &&
0432             !::boost::type_erasure::detail::is_binding_arg<U>::value &&
0433             !::boost::type_erasure::detail::is_static_binding_arg<U>::value
0434         >::type* = nullptr
0435     >
0436     any_constructor_impl(U&& data_arg, const static_binding<Map>& b)
0437       : _boost_type_erasure_table((
0438             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
0439             b
0440         )),
0441         _boost_type_erasure_data(std::forward<U>(data_arg))
0442     {
0443         BOOST_MPL_ASSERT((::boost::is_same<
0444             typename ::boost::mpl::at<Map, T>::type, ::boost::decay_t<U> >));
0445     }
0446     // converting constructor
0447     template<class U,
0448         typename ::boost::enable_if_c<
0449             ::boost::type_erasure::is_subconcept<
0450                 Concept, typename ::boost::type_erasure::detail::safe_concept_of<U>::type,
0451                 typename ::boost::mpl::if_c< ::boost::is_same<T, ::boost::type_erasure::detail::safe_placeholder_t<U> >::value,
0452                     void,
0453                     ::boost::mpl::map1<
0454                         ::boost::mpl::pair<T, ::boost::type_erasure::detail::safe_placeholder_t<U> >
0455                     >
0456                 >::type
0457             >::value
0458         >::type* = nullptr
0459     >
0460     any_constructor_impl(U&& other)
0461       : _boost_type_erasure_table(
0462             ::boost::type_erasure::detail::access::table(other),
0463             typename ::boost::mpl::if_c< ::boost::is_same<T, ::boost::type_erasure::detail::safe_placeholder_t<U> >::value,
0464 #ifndef BOOST_TYPE_ERASURE_USE_MP11
0465                 ::boost::type_erasure::detail::substitution_map< ::boost::mpl::map0<> >,
0466 #else
0467                 ::boost::type_erasure::detail::make_identity_placeholder_map<Concept>,
0468 #endif
0469                 ::boost::mpl::map1<
0470                     ::boost::mpl::pair<
0471                         T,
0472                         ::boost::type_erasure::detail::safe_placeholder_t<U>
0473                     >
0474                 >
0475             >::type()
0476         ),
0477         _boost_type_erasure_data(::boost::type_erasure::call(
0478             ::boost::type_erasure::detail::make(
0479                 false? other._boost_type_erasure_deduce_constructor(std::forward<U>(other)) : 0
0480             ), std::forward<U>(other))
0481         )
0482     {}
0483     template<class U,
0484         typename ::boost::enable_if_c<
0485             ::boost::type_erasure::detail::is_any_arg<U>::value
0486         >::type* = nullptr
0487     >
0488     any_constructor_impl(U&& other, const binding<Concept>& binding_arg)
0489       : _boost_type_erasure_table(binding_arg),
0490         _boost_type_erasure_data(::boost::type_erasure::call(
0491             ::boost::type_erasure::detail::make(
0492                 false? other._boost_type_erasure_deduce_constructor(std::forward<U>(other)) : 0
0493             ), std::forward<U>(other))
0494         )
0495     {}
0496     template<class U, class Map,
0497         typename ::boost::enable_if_c<
0498             ::boost::type_erasure::is_subconcept<
0499                 Concept, typename ::boost::type_erasure::detail::safe_concept_of<U>::type,
0500                 Map
0501             >::value
0502         >::type* = nullptr
0503     >
0504     any_constructor_impl(U&& other, const static_binding<Map>& binding_arg)
0505       : _boost_type_erasure_table(::boost::type_erasure::detail::access::table(other), binding_arg),
0506         _boost_type_erasure_data(::boost::type_erasure::call(
0507             ::boost::type_erasure::detail::make(
0508                 false? other._boost_type_erasure_deduce_constructor(std::forward<U>(other)) : 0
0509             ), std::forward<U>(other))
0510         )
0511     {}
0512     // copy and move constructors are a special case of the converting
0513     // constructors, but must be defined separately to keep C++ happy.
0514     any_constructor_impl(const any_constructor_impl& other)
0515       : _boost_type_erasure_table(
0516             ::boost::type_erasure::detail::access::table(other)
0517         ),
0518         _boost_type_erasure_data(::boost::type_erasure::call(
0519             ::boost::type_erasure::detail::make(
0520                 false? other._boost_type_erasure_deduce_constructor(
0521                     static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type const&>(other)) : 0
0522             ), other)
0523         )
0524     {}
0525     any_constructor_impl(any_constructor_impl& other)
0526       : _boost_type_erasure_table(
0527             ::boost::type_erasure::detail::access::table(other)
0528         ),
0529         _boost_type_erasure_data(::boost::type_erasure::call(
0530             ::boost::type_erasure::detail::make(
0531                 false? other._boost_type_erasure_deduce_constructor(
0532                     static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type &>(other)) : 0
0533             ), other)
0534         )
0535     {}
0536     any_constructor_impl(any_constructor_impl&& other)
0537       : _boost_type_erasure_table(
0538             ::boost::type_erasure::detail::access::table(other)
0539         ),
0540         _boost_type_erasure_data(::boost::type_erasure::call(
0541             ::boost::type_erasure::detail::make(
0542                 false? other._boost_type_erasure_deduce_constructor(
0543                     static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type &&>(other)) : 0
0544             ), std::move(other))
0545         )
0546     {}
0547 
0548     template<class R, class... A, class... U>
0549     const _boost_type_erasure_table_type& _boost_type_erasure_extract_table(
0550         ::boost::type_erasure::constructible<R(A...)>*,
0551         U&&... u)
0552     {
0553         return *::boost::type_erasure::detail::extract_table(static_cast<void(*)(A...)>(0), u...);
0554     }
0555     // forwarding constructor
0556     template<class... U,
0557         typename ::boost::enable_if_c<
0558             ::boost::type_erasure::detail::has_constructor<any_constructor_impl, U...>::value
0559         >::type* = nullptr
0560     >
0561     explicit any_constructor_impl(U&&... u)
0562       : _boost_type_erasure_table(
0563             _boost_type_erasure_extract_table(
0564                 false? this->_boost_type_erasure_deduce_constructor(std::forward<U>(u)...) : 0,
0565                 std::forward<U>(u)...
0566             )
0567         ),
0568         _boost_type_erasure_data(
0569             ::boost::type_erasure::call(
0570                 ::boost::type_erasure::detail::make(
0571                     false? this->_boost_type_erasure_deduce_constructor(std::forward<U>(u)...) : 0
0572                 ),
0573                 std::forward<U>(u)...
0574             )
0575         )
0576     {}
0577     template<class... U,
0578         typename ::boost::enable_if_c<
0579             ::boost::type_erasure::detail::has_constructor<any_constructor_impl, U...>::value
0580         >::type* = nullptr
0581     >
0582     explicit any_constructor_impl(const binding<Concept>& binding_arg, U&&... u)
0583       : _boost_type_erasure_table(binding_arg),
0584         _boost_type_erasure_data(
0585             ::boost::type_erasure::call(
0586                 binding_arg,
0587                 ::boost::type_erasure::detail::make(
0588                     false? this->_boost_type_erasure_deduce_constructor(std::forward<U>(u)...) : 0
0589                 ),
0590                 std::forward<U>(u)...
0591             )
0592         )
0593     {}
0594 
0595     // The assignment operator and destructor must be defined here rather
0596     // than in any to avoid implicitly deleting the move constructor.
0597 
0598     any_constructor_impl& operator=(const any_constructor_impl& other)
0599     {
0600         static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type*>(this)->_boost_type_erasure_resolve_assign(
0601             static_cast<const typename _boost_type_erasure_base::_boost_type_erasure_derived_type&>(other));
0602         return *this;
0603     }
0604 
0605     any_constructor_impl& operator=(any_constructor_impl& other)
0606     {
0607         static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type*>(this)->_boost_type_erasure_resolve_assign(
0608             static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type&>(other));
0609         return *this;
0610     }
0611 
0612     any_constructor_impl& operator=(any_constructor_impl&& other)
0613     {
0614         static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type*>(this)->_boost_type_erasure_resolve_assign(
0615             static_cast<typename _boost_type_erasure_base::_boost_type_erasure_derived_type&&>(other));
0616         return *this;
0617     }
0618 
0619     ~any_constructor_impl()
0620     {
0621         _boost_type_erasure_table.template find<
0622             ::boost::type_erasure::destructible<T>
0623         >()(_boost_type_erasure_data);
0624     }
0625 
0626 protected:
0627     friend struct ::boost::type_erasure::detail::access;
0628 
0629     _boost_type_erasure_table_type _boost_type_erasure_table;
0630     ::boost::type_erasure::detail::storage _boost_type_erasure_data;
0631 };
0632 
0633 namespace detail {
0634 
0635 #endif
0636 
0637 template<class T>
0638 struct is_rvalue_for_any : 
0639     ::boost::mpl::not_<
0640         ::boost::is_lvalue_reference<T>
0641     >
0642 {};
0643 
0644 template<class C, class P>
0645 struct is_rvalue_for_any<any<C, P> > :
0646     ::boost::mpl::not_<
0647         ::boost::is_lvalue_reference<P>
0648     >
0649 {};
0650 
0651 }
0652 
0653 /**
0654  * The class template @ref any can store any object that
0655  * models a specific \Concept.  It dispatches all
0656  * the functions defined by the \Concept to the contained type
0657  * at runtime.
0658  *
0659  * \tparam Concept The \Concept that the stored type should model.
0660  * \tparam T A @ref placeholder specifying which type this is.
0661  *
0662  * \see concept_of, placeholder_of, \any_cast, \is_empty, \binding_of, \typeid_of
0663  */
0664 template<class Concept, class T = _self>
0665 class any :
0666 #ifdef BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS
0667     public ::boost::type_erasure::any_constructor_control<
0668         ::boost::type_erasure::any_constructor_impl<
0669 
0670             Concept,
0671             T
0672         >
0673     >
0674 #else
0675     public ::boost::type_erasure::detail::compute_bases<
0676         ::boost::type_erasure::any<Concept, T>,
0677         Concept,
0678         T
0679     >::type
0680 #endif
0681 {
0682     typedef ::boost::type_erasure::binding<Concept> table_type;
0683 public:
0684     /** INTERNAL ONLY */
0685     typedef Concept _boost_type_erasure_concept_type;
0686 
0687 #if defined(BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS)
0688     using _boost_type_erasure_base = ::boost::type_erasure::any_constructor_control<
0689         ::boost::type_erasure::any_constructor_impl<
0690             Concept,
0691             T
0692         >
0693     >;
0694     using _boost_type_erasure_base::_boost_type_erasure_base;
0695 #else
0696 
0697     /** INTERNAL ONLY */
0698     any(const ::boost::type_erasure::detail::storage& data_arg, const table_type& table_arg)
0699       : table(table_arg),
0700         data(data_arg)
0701     {}
0702 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0703     /** INTERNAL ONLY */
0704     any(::boost::type_erasure::detail::storage&& data_arg, const table_type& table_arg)
0705       : table(table_arg),
0706         data(data_arg)
0707     {}
0708 #endif
0709     /**
0710      * Constructs an empty @ref any.
0711      *
0712      * Except as otherwise noted, all operations on an
0713      * empty @ref any result in a @ref bad_function_call exception.
0714      * The copy-constructor of an empty @ref any creates another
0715      * null @ref any.  The destructor of an empty @ref any is a no-op.
0716      * Comparison operators treat all empty @ref any "anys" as equal.
0717      * \typeid_of applied to an empty @ref any returns @c typeid(void).
0718      *
0719      * An @ref any which does not include @ref relaxed in its
0720      * \Concept can never be null.
0721      *
0722      * \pre @ref relaxed must be in @c Concept.
0723      *
0724      * \throws Nothing.
0725      *
0726      * @see \is_empty
0727      */
0728     any()
0729     {
0730         BOOST_MPL_ASSERT((::boost::type_erasure::is_relaxed<Concept>));
0731         data.data = 0;
0732     }
0733 
0734 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0735 
0736     template<class U>
0737     any(const U& data_arg)
0738       : table((
0739             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
0740             ::boost::type_erasure::make_binding<
0741                 ::boost::mpl::map1< ::boost::mpl::pair<T, U> >
0742             >()
0743         )),
0744         data(data_arg)
0745     {}
0746     template<class U, class Map>
0747     any(const U& data_arg, const static_binding<Map>& binding_arg)
0748       : table((
0749             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
0750             binding_arg
0751         )),
0752         data(data_arg)
0753     {
0754         BOOST_MPL_ASSERT((::boost::is_same<
0755             typename ::boost::mpl::at<Map, T>::type, U>));
0756     }
0757 
0758 #else
0759 
0760     /**
0761      * Constructs an @ref any to hold a copy of @c data.
0762      * The @c Concept will be instantiated with the
0763      * placeholder @c T bound to U.
0764      *
0765      * \param data The object to store in the @ref any.
0766      *
0767      * \pre @c U is a model of @c Concept.
0768      * \pre @c U must be \CopyConstructible.
0769      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
0770      *
0771      * \throws std::bad_alloc or whatever that the copy
0772      *         constructor of @c U throws.
0773      *
0774      * \note This constructor never matches if the argument is
0775      *       an @ref any, @ref binding, or @ref static_binding.
0776      */
0777     template<class U>
0778     any(U&& data_arg)
0779       : table((
0780             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type),
0781             ::boost::type_erasure::make_binding<
0782                 ::boost::mpl::map1< ::boost::mpl::pair<T, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type> >
0783             >()
0784         )),
0785         data(std::forward<U>(data_arg))
0786     {}
0787     /**
0788      * Constructs an @ref any to hold a copy of @c data
0789      * with explicitly specified placeholder bindings.
0790      *
0791      * \param data The object to store in the @ref any.
0792      * \param binding Specifies the types that
0793      *        all the placeholders should bind to.
0794      *
0795      * \pre @c U is a model of @c Concept.
0796      * \pre @c U must be \CopyConstructible.
0797      * \pre @c Map is an MPL map with an entry for every
0798      *         non-deduced placeholder referred to by @c Concept.
0799      * \pre @c @c T must map to @c U in @c Map.
0800      *
0801      * \throws std::bad_alloc or whatever that the copy
0802      *         constructor of @c U throws.
0803      *
0804      * \note This constructor never matches if the argument is an @ref any.
0805      */
0806     template<class U, class Map>
0807     any(U&& data_arg, const static_binding<Map>& binding_arg)
0808       : table((
0809             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
0810             binding_arg
0811         )),
0812         data(std::forward<U>(data_arg))
0813     {
0814         BOOST_MPL_ASSERT((::boost::is_same<
0815             typename ::boost::mpl::at<Map, T>::type, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type>));
0816     }
0817 
0818 #endif
0819 
0820     // Handle array/function-to-pointer decay
0821     /** INTERNAL ONLY */
0822     template<class U>
0823     any(U* data_arg)
0824       : table((
0825             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U*),
0826             ::boost::type_erasure::make_binding<
0827                 ::boost::mpl::map1< ::boost::mpl::pair<T, U*> >
0828             >()
0829         )),
0830         data(data_arg)
0831     {}
0832     /** INTERNAL ONLY */
0833     template<class U, class Map>
0834     any(U* data_arg, const static_binding<Map>& binding_arg)
0835       : table((
0836             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
0837             binding_arg
0838         )),
0839         data(data_arg)
0840     {
0841         BOOST_MPL_ASSERT((::boost::is_same<
0842             typename ::boost::mpl::at<Map, T>::type, U*>));
0843     }
0844     /**
0845      * Copies an @ref any.
0846      *
0847      * \param other The object to make a copy of.
0848      *
0849      * \pre @c Concept must contain @ref constructible "constructible<T(const T&)>".
0850      *     (This is included in @ref copy_constructible "copy_constructible<T>")
0851      *
0852      * \throws std::bad_alloc or whatever that the copy
0853      *         constructor of the contained type throws.
0854      */
0855     any(const any& other)
0856       : table(other.table),
0857         data(::boost::type_erasure::call(constructible<T(const T&)>(), other))
0858     {}
0859     /**
0860      * Upcasts from an @ref any with stricter requirements to
0861      * an @ref any with weaker requirements.
0862      *
0863      * \param other The object to make a copy of.
0864      *
0865      * \pre @c Concept must contain @ref constructible "constructible<T(const T&)>".
0866      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
0867      * \pre After substituting @c T for @c Tag2, the requirements of
0868      *      @c Concept2 must be a superset of the requirements of
0869      *      @c Concept.
0870      *
0871      * \throws std::bad_alloc or whatever that the copy
0872      *         constructor of the contained type throws.
0873      */
0874     template<class Concept2, class Tag2>
0875     any(const any<Concept2, Tag2>& other)
0876       : table(
0877             ::boost::type_erasure::detail::access::table(other),
0878             ::boost::mpl::map1<
0879                 ::boost::mpl::pair<
0880                     T,
0881                     typename ::boost::remove_const<
0882                         typename ::boost::remove_reference<Tag2>::type
0883                     >::type
0884                 >
0885             >()
0886         ),
0887         data(::boost::type_erasure::call(
0888             constructible<
0889                 typename ::boost::remove_const<
0890                     typename boost::remove_reference<Tag2>::type
0891                 >::type(const typename boost::remove_reference<Tag2>::type&)
0892             >(), other)
0893         )
0894     {}
0895     /**
0896      * Constructs an @ref any from another @ref any.
0897      *
0898      * \param other The object to make a copy of.
0899      * \param binding Specifies the mapping between the placeholders
0900      *        used by the two concepts.
0901      *
0902      * \pre @c Concept must contain @ref constructible "constructible<T(const T&)>".
0903      * \pre @c Map must be an MPL map with keys for all the non-deduced
0904      *      placeholders used by @c Concept and values for the corresponding
0905      *      placeholders in @c Concept2.
0906      * \pre After substituting placeholders according to @c Map, the
0907      *      requirements of @c Concept2 must be a superset of the
0908      *      requirements of @c Concept.
0909      *
0910      * \throws std::bad_alloc or whatever that the copy
0911      *         constructor of the contained type throws.
0912      */
0913     template<class Concept2, class Tag2, class Map>
0914     any(const any<Concept2, Tag2>& other, const static_binding<Map>& binding_arg)
0915       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
0916         data(::boost::type_erasure::call(
0917             constructible<
0918                 typename ::boost::remove_const<
0919                     typename boost::remove_reference<Tag2>::type
0920                 >::type(const typename boost::remove_reference<Tag2>::type&)
0921             >(), other)
0922         )
0923     {}
0924     /**
0925      * Constructs an @ref any from another @ref any.
0926      *
0927      * \param other The object to make a copy of.
0928      * \param binding Specifies the bindings of placeholders to actual types.
0929      *
0930      * \pre @c Concept must contain @ref constructible "constructible<T(const T&)>".
0931      * \pre The type stored in @c other must match the type expected by
0932      *      @c binding.
0933      *
0934      * \post binding_of(*this) == @c binding
0935      *
0936      * \throws std::bad_alloc or whatever that the copy
0937      *         constructor of the contained type throws.
0938      *
0939      * \warning This constructor is potentially dangerous, as it cannot
0940      *          check at compile time whether the arguments match.
0941      */
0942     template<class Concept2, class Tag2>
0943     any(const any<Concept2, Tag2>& other, const binding<Concept>& binding_arg)
0944       : table(binding_arg),
0945         data(::boost::type_erasure::call(
0946             constructible<
0947                 typename ::boost::remove_const<
0948                     typename boost::remove_reference<Tag2>::type
0949                 >::type(const typename boost::remove_reference<Tag2>::type&)
0950             >(), other)
0951         )
0952     {}
0953 
0954 #ifdef BOOST_TYPE_ERASURE_DOXYGEN
0955 
0956     /**
0957      * Calls a constructor of the contained type.  The bindings
0958      * will be deduced from the arguments.
0959      *
0960      * \param arg The arguments to be passed to the underlying constructor.
0961      *
0962      * \pre @c Concept must contain an instance of @ref constructible which
0963      *      can be called with these arguments.
0964      * \pre At least one of the arguments must by an @ref any with the
0965      *      same @c Concept as this.
0966      * \pre The bindings of all the arguments that are @ref any's, must
0967      *      be the same.
0968      *
0969      * \throws std::bad_alloc or whatever that the
0970      *         constructor of the contained type throws.
0971      *
0972      * \note This constructor is never chosen if any other constructor
0973      *       can be called instead.
0974      */
0975     template<class... U>
0976     explicit any(U&&... arg);
0977 
0978     /**
0979      * Calls a constructor of the contained type.
0980      *
0981      * \param binding Specifies the bindings of placeholders to actual types.
0982      * \param arg The arguments to be passed to the underlying constructor.
0983      *
0984      * \pre @c Concept must contain a matching instance of @ref constructible.
0985      * \pre The contained type of every argument that is an @ref any, must
0986      *      be the same as that specified by @c binding.
0987      *
0988      * \post binding_of(*this) == @c binding
0989      *
0990      * \throws std::bad_alloc or whatever that the
0991      *         constructor of the contained type throws.
0992      */
0993     template<class... U>
0994     explicit any(const binding<Concept>& binding_arg, U&&... arg)
0995       : table(binding_arg),
0996         data(
0997             ::boost::type_erasure::detail::make(
0998                 false? this->_boost_type_erasure_deduce_constructor(arg...) : 0
0999             )(arg...)
1000         )
1001     {}
1002 
1003 #else
1004 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1005     any(any&& other)
1006       : table(::boost::type_erasure::detail::access::table(other)),
1007         data(::boost::type_erasure::call(
1008             ::boost::type_erasure::detail::make(
1009                 false? this->_boost_type_erasure_deduce_constructor(std::move(other)) : 0
1010             ), std::move(other))
1011         )
1012     {}
1013     any(any& other)
1014       : table(::boost::type_erasure::detail::access::table(other)),
1015         data(::boost::type_erasure::call(
1016             ::boost::type_erasure::detail::make(
1017                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1018             ), other)
1019         )
1020     {}
1021     template<class Concept2, class Tag2>
1022     any(any<Concept2, Tag2>& other)
1023       : table(
1024             ::boost::type_erasure::detail::access::table(other),
1025             ::boost::mpl::map1<
1026                 ::boost::mpl::pair<
1027                     T,
1028                     typename ::boost::remove_const<
1029                         typename ::boost::remove_reference<Tag2>::type
1030                     >::type
1031                 >
1032             >()
1033         ),
1034         data(::boost::type_erasure::call(
1035             ::boost::type_erasure::detail::make(
1036                 false? other._boost_type_erasure_deduce_constructor(other) : 0
1037             ), other)
1038         )
1039     {}
1040     template<class Concept2, class Tag2>
1041     any(any<Concept2, Tag2>&& other)
1042       : table(
1043             ::boost::type_erasure::detail::access::table(other),
1044             ::boost::mpl::map1<
1045                 ::boost::mpl::pair<
1046                     T,
1047                     typename ::boost::remove_const<
1048                         typename ::boost::remove_reference<Tag2>::type
1049                     >::type
1050                 >
1051             >()
1052         ),
1053         data(::boost::type_erasure::call(
1054             ::boost::type_erasure::detail::make(
1055                 false? other._boost_type_erasure_deduce_constructor(std::move(other)) : 0
1056             ), std::move(other))
1057         )
1058     {}
1059 #endif
1060     // construction from a reference
1061     any(const any<Concept, T&>& other)
1062       : table(::boost::type_erasure::detail::access::table(other)),
1063         data(::boost::type_erasure::call(
1064             ::boost::type_erasure::detail::make(
1065                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1066             ), other)
1067         )
1068     {}
1069     any(any<Concept, T&>& other)
1070       : table(::boost::type_erasure::detail::access::table(other)),
1071         data(::boost::type_erasure::call(
1072             ::boost::type_erasure::detail::make(
1073                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1074             ), other)
1075         )
1076     {}
1077 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1078     any(any<Concept, T&>&& other)
1079       : table(::boost::type_erasure::detail::access::table(other)),
1080         data(::boost::type_erasure::call(
1081             ::boost::type_erasure::detail::make(
1082                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1083             ), other)
1084         )
1085     {}
1086 #endif
1087     any(const any<Concept, const T&>& other)
1088       : table(::boost::type_erasure::detail::access::table(other)),
1089         data(::boost::type_erasure::call(
1090             ::boost::type_erasure::detail::make(
1091                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1092             ), other)
1093         )
1094     {}
1095     any(any<Concept, const T&>& other)
1096       : table(::boost::type_erasure::detail::access::table(other)),
1097         data(::boost::type_erasure::call(
1098             ::boost::type_erasure::detail::make(
1099                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1100             ), other)
1101         )
1102     {}
1103 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1104     any(any<Concept, const T&>&& other)
1105       : table(::boost::type_erasure::detail::access::table(other)),
1106         data(::boost::type_erasure::call(
1107             ::boost::type_erasure::detail::make(
1108                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1109             ), other)
1110         )
1111     {}
1112 #endif
1113 
1114     // disambiguating overloads
1115     template<class U, class Map>
1116     any(U* data_arg, static_binding<Map>& binding_arg)
1117       : table((
1118             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1119             binding_arg
1120         )),
1121         data(data_arg)
1122     {
1123         BOOST_MPL_ASSERT((::boost::is_same<
1124             typename ::boost::mpl::at<Map, T>::type, U*>));
1125     }
1126 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
1127     template<class U, class Map>
1128     any(U& data_arg, static_binding<Map>& binding_arg)
1129       : table((
1130             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1131             binding_arg
1132         )),
1133         data(data_arg)
1134     {
1135         BOOST_MPL_ASSERT((::boost::is_same<
1136             typename ::boost::mpl::at<Map, T>::type, U>));
1137     }
1138     template<class U, class Map>
1139     any(const U& data_arg, static_binding<Map>& binding_arg)
1140       : table((
1141             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1142             binding_arg
1143         )),
1144         data(data_arg)
1145     {
1146         BOOST_MPL_ASSERT((::boost::is_same<
1147             typename ::boost::mpl::at<Map, T>::type, U>));
1148     }
1149     template<class U, class Map>
1150     any(U& data_arg, const static_binding<Map>& binding_arg)
1151       : table((
1152             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1153             binding_arg
1154         )),
1155         data(data_arg)
1156     {
1157         BOOST_MPL_ASSERT((::boost::is_same<
1158             typename ::boost::mpl::at<Map, T>::type, U>));
1159     }
1160 #endif
1161 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1162     template<class U, class Map>
1163     any(U* data_arg, static_binding<Map>&& binding_arg)
1164       : table((
1165             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1166             binding_arg
1167         )),
1168         data(data_arg)
1169     {
1170         BOOST_MPL_ASSERT((::boost::is_same<
1171             typename ::boost::mpl::at<Map, T>::type, U*>));
1172     }
1173     template<class U, class Map>
1174     any(U&& data_arg, static_binding<Map>& binding_arg)
1175       : table((
1176             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1177             binding_arg
1178         )),
1179         data(data_arg)
1180     {
1181         BOOST_MPL_ASSERT((::boost::is_same<
1182             typename ::boost::mpl::at<Map, T>::type, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type>));
1183     }
1184     template<class U, class Map>
1185     any(U&& data_arg, static_binding<Map>&& binding_arg)
1186       : table((
1187             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1188             binding_arg
1189         )),
1190         data(data_arg)
1191     {
1192         BOOST_MPL_ASSERT((::boost::is_same<
1193             typename ::boost::mpl::at<Map, T>::type, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type>));
1194     }
1195 #endif
1196     template<class Concept2, class Tag2, class Map>
1197     any(any<Concept2, Tag2>& other, static_binding<Map>& binding_arg)
1198       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1199         data(::boost::type_erasure::call(
1200             constructible<
1201                 typename ::boost::remove_const<
1202                     typename boost::remove_reference<Tag2>::type
1203                 >::type(const typename boost::remove_reference<Tag2>::type&)
1204             >(), other)
1205         )
1206     {}
1207     template<class Concept2, class Tag2, class Map>
1208     any(any<Concept2, Tag2>& other, const static_binding<Map>& binding_arg)
1209       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1210         data(::boost::type_erasure::call(
1211             constructible<
1212                 typename ::boost::remove_const<
1213                     typename boost::remove_reference<Tag2>::type
1214                 >::type(const typename boost::remove_reference<Tag2>::type&)
1215             >(), other)
1216         )
1217     {}
1218     template<class Concept2, class Tag2, class Map>
1219     any(const any<Concept2, Tag2>& other, static_binding<Map>& binding_arg)
1220       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1221         data(::boost::type_erasure::call(
1222             constructible<
1223                 typename ::boost::remove_const<
1224                     typename boost::remove_reference<Tag2>::type
1225                 >::type(const typename boost::remove_reference<Tag2>::type&)
1226             >(), other)
1227         )
1228     {}
1229     template<class Concept2, class Tag2>
1230     any(any<Concept2, Tag2>& other, binding<Concept>& binding_arg)
1231       : table(binding_arg),
1232         data(::boost::type_erasure::call(
1233             constructible<
1234                 typename ::boost::remove_const<
1235                     typename boost::remove_reference<Tag2>::type
1236                 >::type(const typename boost::remove_reference<Tag2>::type&)
1237             >(), other)
1238         )
1239     {}
1240     template<class Concept2, class Tag2>
1241     any(any<Concept2, Tag2>& other, const binding<Concept>& binding_arg)
1242       : table(binding_arg),
1243         data(::boost::type_erasure::call(
1244             constructible<
1245                 typename ::boost::remove_const<
1246                     typename boost::remove_reference<Tag2>::type
1247                 >::type(const typename boost::remove_reference<Tag2>::type&)
1248             >(), other)
1249         )
1250     {}
1251     template<class Concept2, class Tag2>
1252     any(const any<Concept2, Tag2>& other, binding<Concept>& binding_arg)
1253       : table(binding_arg),
1254         data(::boost::type_erasure::call(
1255             constructible<
1256                 typename ::boost::remove_const<
1257                     typename boost::remove_reference<Tag2>::type
1258                 >::type(const typename boost::remove_reference<Tag2>::type&)
1259             >(), other)
1260         )
1261     {}
1262 
1263 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1264     template<class Concept2, class Tag2, class Map>
1265     any(any<Concept2, Tag2>& other, static_binding<Map>&& binding_arg)
1266       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1267         data(::boost::type_erasure::call(
1268             constructible<
1269                 typename ::boost::remove_const<
1270                     typename boost::remove_reference<Tag2>::type
1271                 >::type(const typename boost::remove_reference<Tag2>::type&)
1272             >(), other)
1273         )
1274     {}
1275     template<class Concept2, class Tag2, class Map>
1276     any(const any<Concept2, Tag2>& other, static_binding<Map>&& binding_arg)
1277       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1278         data(::boost::type_erasure::call(
1279             constructible<
1280                 typename ::boost::remove_const<
1281                     typename boost::remove_reference<Tag2>::type
1282                 >::type(const typename boost::remove_reference<Tag2>::type&)
1283             >(), other)
1284         )
1285     {}
1286     template<class Concept2, class Tag2, class Map>
1287     any(any<Concept2, Tag2>&& other, static_binding<Map>&& binding_arg)
1288       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1289         data(::boost::type_erasure::call(
1290             constructible<
1291                 typename ::boost::remove_const<
1292                     typename boost::remove_reference<Tag2>::type
1293                 >::type(const typename boost::remove_reference<Tag2>::type&)
1294             >(), std::move(other))
1295         )
1296     {}
1297     template<class Concept2, class Tag2, class Map>
1298     any(any<Concept2, Tag2>&& other, static_binding<Map>& binding_arg)
1299       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1300         data(::boost::type_erasure::call(
1301             constructible<
1302                 typename ::boost::remove_const<
1303                     typename boost::remove_reference<Tag2>::type
1304                 >::type(const typename boost::remove_reference<Tag2>::type&)
1305             >(), std::move(other))
1306         )
1307     {}
1308     template<class Concept2, class Tag2, class Map>
1309     any(any<Concept2, Tag2>&& other, const static_binding<Map>& binding_arg)
1310       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
1311         data(::boost::type_erasure::call(
1312             constructible<
1313                 typename ::boost::remove_const<
1314                     typename boost::remove_reference<Tag2>::type
1315                 >::type(const typename boost::remove_reference<Tag2>::type&)
1316             >(), std::move(other))
1317         )
1318     {}
1319     template<class Concept2, class Tag2>
1320     any(any<Concept2, Tag2>& other, binding<Concept>&& binding_arg)
1321       : table(binding_arg),
1322         data(::boost::type_erasure::call(
1323             constructible<
1324                 typename ::boost::remove_const<
1325                     typename boost::remove_reference<Tag2>::type
1326                 >::type(const typename boost::remove_reference<Tag2>::type&)
1327             >(), other)
1328         )
1329     {}
1330     template<class Concept2, class Tag2>
1331     any(const any<Concept2, Tag2>& other, binding<Concept>&& binding_arg)
1332       : table(binding_arg),
1333         data(::boost::type_erasure::call(
1334             constructible<
1335                 typename ::boost::remove_const<
1336                     typename boost::remove_reference<Tag2>::type
1337                 >::type(const typename boost::remove_reference<Tag2>::type&)
1338             >(), other)
1339         )
1340     {}
1341     template<class Concept2, class Tag2>
1342     any(any<Concept2, Tag2>&& other, binding<Concept>&& binding_arg)
1343       : table(binding_arg),
1344         data(::boost::type_erasure::call(
1345             constructible<
1346                 typename ::boost::remove_const<
1347                     typename boost::remove_reference<Tag2>::type
1348                 >::type(const typename boost::remove_reference<Tag2>::type&)
1349             >(), std::move(other))
1350         )
1351     {}
1352     template<class Concept2, class Tag2>
1353     any(any<Concept2, Tag2>&& other, binding<Concept>& binding_arg)
1354       : table(binding_arg),
1355         data(::boost::type_erasure::call(
1356             constructible<
1357                 typename ::boost::remove_const<
1358                     typename boost::remove_reference<Tag2>::type
1359                 >::type(const typename boost::remove_reference<Tag2>::type&)
1360             >(), std::move(other))
1361         )
1362     {}
1363     template<class Concept2, class Tag2>
1364     any(any<Concept2, Tag2>&& other, const binding<Concept>& binding_arg)
1365       : table(binding_arg),
1366         data(::boost::type_erasure::call(
1367             constructible<
1368                 typename ::boost::remove_const<
1369                     typename boost::remove_reference<Tag2>::type
1370                 >::type(const typename boost::remove_reference<Tag2>::type&)
1371             >(), std::move(other))
1372         )
1373     {}
1374 #endif
1375 
1376     // One argument is a special case.  The argument must be an any
1377     // and the constructor must be explicit.
1378     template<class Tag2>
1379     explicit any(const any<Concept, Tag2>& other)
1380       : table(::boost::type_erasure::detail::access::table(other)),
1381         data(::boost::type_erasure::call(
1382             ::boost::type_erasure::detail::make(
1383                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1384             ), other)
1385         )
1386     {}
1387     template<class Tag2>
1388     explicit any(any<Concept, Tag2>& other)
1389       : table(::boost::type_erasure::detail::access::table(other)),
1390         data(::boost::type_erasure::call(
1391             ::boost::type_erasure::detail::make(
1392                 false? this->_boost_type_erasure_deduce_constructor(other) : 0
1393             ), other)
1394         )
1395     {}
1396 
1397 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1398     template<class Tag2>
1399     explicit any(any<Concept, Tag2>&& other)
1400       : table(::boost::type_erasure::detail::access::table(other)),
1401         data(::boost::type_erasure::call(
1402             ::boost::type_erasure::detail::make(
1403                 false? this->_boost_type_erasure_deduce_constructor(std::move(other)) : 0
1404             ), std::move(other))
1405         )
1406     {}
1407 #endif
1408 
1409     explicit any(const binding<Concept>& binding_arg)
1410       : table(binding_arg),
1411         data(
1412             ::boost::type_erasure::call(
1413                 binding_arg,
1414                 ::boost::type_erasure::constructible<T()>()
1415             )
1416         )
1417     {}
1418     explicit any(binding<Concept>& binding_arg)
1419       : table(binding_arg),
1420         data(
1421             ::boost::type_erasure::call(
1422                 binding_arg,
1423                 ::boost::type_erasure::constructible<T()>()
1424             )
1425         )
1426     {}
1427 
1428 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1429 
1430     explicit any(binding<Concept>&& binding_arg)
1431       : table(binding_arg),
1432         data(
1433             ::boost::type_erasure::call(
1434                 binding_arg,
1435                 ::boost::type_erasure::constructible<T()>()
1436             )
1437         )
1438     {}
1439 
1440 #endif
1441 
1442 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
1443 
1444     template<class R, class... A, class... U>
1445     const table_type& _boost_type_erasure_extract_table(
1446         ::boost::type_erasure::constructible<R(A...)>*,
1447         U&&... u)
1448     {
1449         return *::boost::type_erasure::detail::extract_table(static_cast<void(*)(A...)>(0), u...);
1450     }
1451 
1452     template<class U0, class U1, class... U>
1453     any(U0&& u0, U1&& u1, U&&... u)
1454       : table(
1455             _boost_type_erasure_extract_table(
1456                 false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...) : 0,
1457                 std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...
1458             )
1459         ),
1460         data(
1461             ::boost::type_erasure::call(
1462                 ::boost::type_erasure::detail::make(
1463                     false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...) : 0
1464                 ),
1465                 std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...
1466             )
1467         )
1468     {}
1469 
1470     template<class U0, class... U>
1471     any(const binding<Concept>& binding_arg, U0&& u0, U&&... u)
1472       : table(binding_arg),
1473         data(
1474             ::boost::type_erasure::call(
1475                 binding_arg,
1476                 ::boost::type_erasure::detail::make(
1477                     false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U>(u)...) : 0
1478                 ),
1479                 std::forward<U0>(u0), std::forward<U>(u)...
1480             )
1481         )
1482     {}
1483     
1484     // disambiguating overloads
1485     template<class U0, class... U>
1486     any(binding<Concept>& binding_arg, U0&& u0, U&&... u)
1487       : table(binding_arg),
1488         data(
1489             ::boost::type_erasure::call(
1490                 binding_arg,
1491                 ::boost::type_erasure::detail::make(
1492                     false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U>(u)...) : 0
1493                 ),
1494                 std::forward<U0>(u0), std::forward<U>(u)...
1495             )
1496         )
1497     {}
1498     template<class U0, class... U>
1499     any(binding<Concept>&& binding_arg, U0&& u0, U&&... u)
1500       : table(binding_arg),
1501         data(
1502             ::boost::type_erasure::call(
1503                 binding_arg,
1504                 ::boost::type_erasure::detail::make(
1505                     false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U>(u)...) : 0
1506                 ),
1507                 std::forward<U0>(u0), std::forward<U>(u)...
1508             )
1509         )
1510     {}
1511 
1512 #else
1513 
1514 #include <boost/type_erasure/detail/construct.hpp>
1515 
1516 #endif
1517 
1518 #endif
1519     
1520     /** INTERNAL ONLY */
1521     any& operator=(const any& other)
1522     {
1523         _boost_type_erasure_resolve_assign(other);
1524         return *this;
1525     }
1526     /** INTERNAL ONLY */
1527     any& operator=(any& other)
1528     {
1529         _boost_type_erasure_resolve_assign(other);
1530         return *this;
1531     }
1532 
1533 #endif // BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS
1534 
1535 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
1536     template<class U>
1537     any& operator=(U& other)
1538     {
1539         _boost_type_erasure_resolve_assign(other);
1540         return *this;
1541     }
1542     template<class U>
1543     any& operator=(const U& other)
1544     {
1545         _boost_type_erasure_resolve_assign(other);
1546         return *this;
1547     }
1548 #else
1549 #ifndef BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS
1550     /** INTERNAL ONLY */
1551     any& operator=(any&& other)
1552     {
1553         _boost_type_erasure_resolve_assign(std::move(other));
1554         return *this;
1555     }
1556 #endif
1557     /**
1558      * Assigns to an @ref any.
1559      *
1560      * If an appropriate overload of @ref assignable is not available
1561      * and @ref relaxed is in @c Concept, falls back on
1562      * constructing from @c other.
1563      *
1564      * \note If @c U is an @ref any, then this can decide dynamically
1565      *       whether to use construction based on the type stored in other.
1566      *
1567      * \throws Whatever the assignment operator of the contained
1568      *         type throws.  When falling back on construction,
1569      *         throws @c std::bad_alloc or whatever the move (or copy)
1570      *         constructor of the contained type throws.  In
1571      *         this case move assignment provides the strong exception
1572      *         guarantee.  When calling a (move) assignment operator
1573      *         of the contained type, the exception guarantee is
1574      *         whatever the contained type provides.
1575      */
1576     template<class U>
1577     any& operator=(U&& other)
1578     {
1579         _boost_type_erasure_resolve_assign(std::forward<U>(other));
1580         return *this;
1581     }
1582 #endif
1583 
1584 #ifndef BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS
1585     /**
1586      * \pre @c Concept includes @ref destructible "destructible<T>".
1587      */
1588     ~any()
1589     {
1590         ::boost::type_erasure::detail::access::table(*this).template find<
1591             ::boost::type_erasure::destructible<T>
1592         >()(::boost::type_erasure::detail::access::data(*this));
1593     }
1594 #endif
1595 
1596 #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
1597     /** INTERNAL ONLY */
1598     operator param<Concept, T&>() &
1599     {
1600         return param<Concept, T&>(
1601             boost::type_erasure::detail::access::data(*this),
1602             boost::type_erasure::detail::access::table(*this));
1603     }
1604     /** INTERNAL ONLY */
1605     operator param<Concept, T&&>() && {
1606         return param<Concept, T&&>(
1607             boost::type_erasure::detail::access::data(*this),
1608             boost::type_erasure::detail::access::table(*this));
1609     }
1610 #endif
1611 private:
1612 #ifndef BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS
1613     /** INTERNAL ONLY */
1614     void _boost_type_erasure_swap(any& other)
1615     {
1616         ::std::swap(data, other.data);
1617         ::std::swap(table, other.table);
1618     }
1619 #else
1620     void _boost_type_erasure_swap(any& other)
1621     {
1622         ::std::swap(this->_boost_type_erasure_data, other._boost_type_erasure_data);
1623         ::std::swap(this->_boost_type_erasure_table, other._boost_type_erasure_table);
1624     }
1625 #endif
1626 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1627     /** INTERNAL ONLY */
1628     template<class Other>
1629     void _boost_type_erasure_resolve_assign(Other&& other)
1630     {
1631         _boost_type_erasure_assign_impl(
1632             std::forward<Other>(other),
1633             false? this->_boost_type_erasure_deduce_assign(
1634                 ::boost::type_erasure::detail::make_fallback(
1635                     std::forward<Other>(other),
1636                     ::boost::mpl::bool_<
1637                         sizeof(
1638                             ::boost::type_erasure::detail::check_overload(
1639                                 ::boost::declval<any&>().
1640                                     _boost_type_erasure_deduce_assign(std::forward<Other>(other))
1641                             )
1642                         ) == sizeof(::boost::type_erasure::detail::yes)
1643                     >()
1644                 )
1645             ) : 0,
1646             ::boost::type_erasure::is_relaxed<Concept>()
1647         );
1648     }
1649     /** INTERNAL ONLY */
1650     template<class Other, class U>
1651     void _boost_type_erasure_assign_impl(
1652         Other&& other,
1653         const assignable<T, U>*,
1654         ::boost::mpl::false_)
1655     {
1656         ::boost::type_erasure::call(assignable<T, U>(), *this, std::forward<Other>(other));
1657     }
1658     /** INTERNAL ONLY */
1659     template<class Other, class U>
1660     void _boost_type_erasure_assign_impl(
1661         Other&& other,
1662         const assignable<T, U>*,
1663         ::boost::mpl::true_)
1664     {
1665         ::boost::type_erasure::call(assignable<T, U>(), *this, std::forward<Other>(other));
1666     }
1667     /** INTERNAL ONLY */
1668     template<class Other>
1669     void _boost_type_erasure_assign_impl(
1670         Other&& other,
1671         const void*,
1672         ::boost::mpl::true_)
1673     {
1674         any temp(std::forward<Other>(other));
1675         _boost_type_erasure_swap(temp);
1676     }
1677 #else
1678     /** INTERNAL ONLY */
1679     template<class Other>
1680     void _boost_type_erasure_resolve_assign(Other& other)
1681     {
1682         _boost_type_erasure_assign_impl(
1683             other,
1684             false? this->_boost_type_erasure_deduce_assign(
1685                 ::boost::type_erasure::detail::make_fallback(
1686                     other,
1687                     ::boost::mpl::bool_<
1688                         sizeof(
1689                             ::boost::type_erasure::detail::check_overload(
1690                                 ::boost::declval<any&>().
1691                                     _boost_type_erasure_deduce_assign(other)
1692                             )
1693                         ) == sizeof(::boost::type_erasure::detail::yes)
1694                     >()
1695                 )
1696             ) : 0,
1697             ::boost::type_erasure::is_relaxed<Concept>()
1698         );
1699     }
1700     /** INTERNAL ONLY */
1701     template<class Other, class U>
1702     void _boost_type_erasure_assign_impl(
1703         Other& other,
1704         const assignable<T, U>*,
1705         ::boost::mpl::false_)
1706     {
1707         ::boost::type_erasure::call(assignable<T, U>(), *this, other);
1708     }
1709     /** INTERNAL ONLY */
1710     template<class Other, class U>
1711     void _boost_type_erasure_assign_impl(
1712         Other& other,
1713         const assignable<T, U>*,
1714         ::boost::mpl::true_)
1715     {
1716         ::boost::type_erasure::call(assignable<T, U>(), *this, other);
1717     }
1718     /** INTERNAL ONLY */
1719     template<class Other>
1720     void _boost_type_erasure_assign_impl(
1721         Other& other,
1722         const void*,
1723         ::boost::mpl::true_)
1724     {
1725         any temp(other);
1726         _boost_type_erasure_swap(temp);
1727     }
1728 #endif
1729     /** INTERNAL ONLY */
1730     template<class Concept2, class Tag2>
1731     void _boost_type_erasure_resolve_assign(const any<Concept2, Tag2>& other)
1732     {
1733         _boost_type_erasure_resolve_assign_any(other);
1734     }
1735     /** INTERNAL ONLY */
1736     template<class Concept2, class Tag2>
1737     void _boost_type_erasure_resolve_assign(any<Concept2, Tag2>& other)
1738     {
1739         _boost_type_erasure_resolve_assign_any(other);
1740     }
1741 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1742     /** INTERNAL ONLY */
1743     template<class Concept2, class Tag2>
1744     void _boost_type_erasure_resolve_assign(any<Concept2, Tag2>&& other)
1745     {
1746         _boost_type_erasure_resolve_assign_any(std::move(other));
1747     }
1748     /** INTERNAL ONLY */
1749     template<class Other>
1750     void _boost_type_erasure_resolve_assign_any(Other&& other)
1751     {
1752         _boost_type_erasure_assign_impl(
1753             std::forward<Other>(other),
1754             false? this->_boost_type_erasure_deduce_assign(
1755                 ::boost::type_erasure::detail::make_fallback(
1756                     std::forward<Other>(other),
1757                     ::boost::mpl::bool_<
1758                         sizeof(
1759                             ::boost::type_erasure::detail::check_overload(
1760                                 ::boost::declval<any&>().
1761                                     _boost_type_erasure_deduce_assign(std::forward<Other>(other))
1762                             )
1763                         ) == sizeof(::boost::type_erasure::detail::yes)
1764                     >()
1765                 )
1766             ) : 0,
1767             false? this->_boost_type_erasure_deduce_constructor(
1768                 ::boost::type_erasure::detail::make_fallback(
1769                     std::forward<Other>(other),
1770                     ::boost::mpl::bool_<
1771                         sizeof(
1772                             ::boost::type_erasure::detail::check_overload(
1773                                 ::boost::declval<any&>().
1774                                     _boost_type_erasure_deduce_constructor(std::forward<Other>(other))
1775                             )
1776                         ) == sizeof(::boost::type_erasure::detail::yes)
1777                     >()
1778                 )
1779             ) : 0,
1780             ::boost::type_erasure::is_relaxed<Concept>()
1781         );
1782     }
1783     /** INTERNAL ONLY */
1784     template<class Other, class U>
1785     void _boost_type_erasure_assign_impl(
1786         Other&& other,
1787         const assignable<T, U>*,
1788         const void*,
1789         ::boost::mpl::false_)
1790     {
1791         ::boost::type_erasure::call(assignable<T, U>(), *this, std::forward<Other>(other));
1792     }
1793     /** INTERNAL ONLY */
1794     template<class Other, class U>
1795     void _boost_type_erasure_assign_impl(
1796         Other&& other,
1797         const assignable<T, U>*,
1798         const void*,
1799         ::boost::mpl::true_)
1800     {
1801         ::boost::type_erasure::call(assignable<T, U>(), *this, std::forward<Other>(other));
1802     }
1803     /** INTERNAL ONLY */
1804     template<class Other, class Sig>
1805     void _boost_type_erasure_assign_impl(
1806         Other&& other,
1807         const void*,
1808         const constructible<Sig>*,
1809         ::boost::mpl::true_)
1810     {
1811         any temp(std::forward<Other>(other));
1812         _boost_type_erasure_swap(temp);
1813     }
1814     /** INTERNAL ONLY */
1815     template<class Other, class U, class Sig>
1816     void _boost_type_erasure_assign_impl(
1817         Other&& other,
1818         const assignable<T, U>*,
1819         const constructible<Sig>*,
1820         ::boost::mpl::true_)
1821     {
1822         if(::boost::type_erasure::check_match(assignable<T, U>(), *this, other))  // const reference to other is enough!
1823         {
1824             ::boost::type_erasure::unchecked_call(assignable<T, U>(), *this, std::forward<Other>(other));
1825         }
1826         else
1827         {
1828             any temp(std::forward<Other>(other));
1829             _boost_type_erasure_swap(temp);
1830         }
1831     }
1832 #else
1833     /** INTERNAL ONLY */
1834     template<class Other>
1835     void _boost_type_erasure_resolve_assign_any(Other& other)
1836     {
1837         _boost_type_erasure_assign_impl(
1838             other,
1839             false? this->_boost_type_erasure_deduce_assign(
1840                 ::boost::type_erasure::detail::make_fallback(
1841                     other,
1842                     ::boost::mpl::bool_<
1843                         sizeof(
1844                             ::boost::type_erasure::detail::check_overload(
1845                                 ::boost::declval<any&>().
1846                                     _boost_type_erasure_deduce_assign(other)
1847                             )
1848                         ) == sizeof(::boost::type_erasure::detail::yes)
1849                     >()
1850                 )
1851             ) : 0,
1852             false? this->_boost_type_erasure_deduce_constructor(
1853                 ::boost::type_erasure::detail::make_fallback(
1854                     other,
1855                     ::boost::mpl::bool_<
1856                         sizeof(
1857                             ::boost::type_erasure::detail::check_overload(
1858                                 ::boost::declval<any&>().
1859                                     _boost_type_erasure_deduce_constructor(other)
1860                             )
1861                         ) == sizeof(::boost::type_erasure::detail::yes)
1862                     >()
1863                 )
1864             ) : 0,
1865             ::boost::type_erasure::is_relaxed<Concept>()
1866         );
1867     }
1868     /** INTERNAL ONLY */
1869     template<class Other, class U>
1870     void _boost_type_erasure_assign_impl(
1871         Other& other,
1872         const assignable<T, U>*,
1873         const void*,
1874         ::boost::mpl::false_)
1875     {
1876         ::boost::type_erasure::call(assignable<T, U>(), *this, other);
1877     }
1878     /** INTERNAL ONLY */
1879     template<class Other, class U>
1880     void _boost_type_erasure_assign_impl(
1881         Other& other,
1882         const assignable<T, U>*,
1883         const void*,
1884         ::boost::mpl::true_)
1885     {
1886         ::boost::type_erasure::call(assignable<T, U>(), *this, other);
1887     }
1888     /** INTERNAL ONLY */
1889     template<class Other, class Sig>
1890     void _boost_type_erasure_assign_impl(
1891         Other& other,
1892         const void*,
1893         const constructible<Sig>*,
1894         ::boost::mpl::true_)
1895     {
1896         any temp(other);
1897         _boost_type_erasure_swap(temp);
1898     }
1899     /** INTERNAL ONLY */
1900     template<class Other, class U, class Sig>
1901     void _boost_type_erasure_assign_impl(
1902         Other& other,
1903         const assignable<T, U>*,
1904         const constructible<Sig>*,
1905         ::boost::mpl::true_)
1906     {
1907         if(::boost::type_erasure::check_match(assignable<T, U>(), *this, other))
1908         {
1909             ::boost::type_erasure::unchecked_call(assignable<T, U>(), *this, other);
1910         }
1911         else
1912         {
1913             any temp(other);
1914             _boost_type_erasure_swap(temp);
1915         }
1916     }
1917 #endif
1918     friend struct ::boost::type_erasure::detail::access;
1919 #ifndef BOOST_TYPE_ERASURE_SFINAE_FRIENDLY_CONSTRUCTORS
1920     // The table has to be initialized first for exception
1921     // safety in some constructors.
1922     table_type table;
1923     ::boost::type_erasure::detail::storage data;
1924 #else
1925     template<class Concept2, class T2>
1926     friend struct ::boost::type_erasure::any_constructor_impl;
1927 #endif
1928 };
1929 
1930 template<class Concept, class T>
1931 class any<Concept, T&> :
1932     public ::boost::type_erasure::detail::compute_bases<
1933         ::boost::type_erasure::any<Concept, T&>,
1934         Concept,
1935         T
1936     >::type
1937 {
1938     typedef ::boost::type_erasure::binding<Concept> table_type;
1939 public:
1940     /** INTERNAL ONLY */
1941     typedef Concept _boost_type_erasure_concept_type;
1942     /** INTERNAL ONLY */
1943     any(const ::boost::type_erasure::detail::storage& data_arg,
1944         const table_type& table_arg)
1945       : data(data_arg),
1946         table(table_arg)
1947     {}
1948     /**
1949      * Constructs an @ref any from a reference.
1950      *
1951      * \param arg The object to bind the reference to.
1952      *
1953      * \pre @c U is a model of @c Concept.
1954      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
1955      *
1956      * \throws Nothing.
1957      */
1958     template<class U>
1959     any(U& arg
1960 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
1961         ,  typename ::boost::disable_if<
1962             ::boost::mpl::or_<
1963                 ::boost::is_const<U>,
1964                 ::boost::type_erasure::detail::is_any<U>
1965             >
1966         >::type* = 0
1967 #endif
1968         )
1969       : table((
1970             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
1971             ::boost::type_erasure::make_binding<
1972                 ::boost::mpl::map1< ::boost::mpl::pair<T, U> >
1973             >()
1974         ))
1975     {
1976         data.data = ::boost::addressof(arg);
1977     }
1978     /**
1979      * Constructs an @ref any from a reference.
1980      *
1981      * \param arg The object to bind the reference to.
1982      * \param binding Specifies the actual types that
1983      *        all the placeholders should bind to.
1984      *
1985      * \pre @c U is a model of @c Concept.
1986      * \pre @c Map is an MPL map with an entry for every
1987      *         non-deduced placeholder referred to by @c Concept.
1988      *
1989      * \throws Nothing.
1990      */
1991     template<class U, class Map>
1992     any(U& arg, const static_binding<Map>& binding_arg)
1993       : table((
1994             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
1995             binding_arg
1996         ))
1997     {
1998         BOOST_MPL_ASSERT((::boost::is_same<
1999             typename ::boost::mpl::at<Map, T>::type, U>));
2000         data.data = ::boost::addressof(arg);
2001     }
2002     /**
2003      * Constructs an @ref any from another reference.
2004      *
2005      * \param other The reference to copy.
2006      *
2007      * \throws Nothing.
2008      */
2009     any(const any& other)
2010       : data(other.data),
2011         table(other.table)
2012     {}
2013 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2014     any(any& other)
2015       : data(other.data),
2016         table(other.table)
2017     {}
2018 #endif
2019     /**
2020      * Constructs an @ref any from another @ref any.
2021      *
2022      * \param other The object to bind the reference to.
2023      *
2024      * \throws Nothing.
2025      */
2026     any(any<Concept, T>& other)
2027       : data(::boost::type_erasure::detail::access::data(other)),
2028         table(::boost::type_erasure::detail::access::table(other))
2029     {}
2030     /**
2031      * Constructs an @ref any from another reference.
2032      *
2033      * \param other The reference to copy.
2034      *
2035      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
2036      * \pre After substituting @c T for @c Tag2, the requirements of
2037      *      @c Concept2 must be a superset of the requirements of
2038      *      @c Concept.
2039      *
2040      * \throws std::bad_alloc
2041      */
2042     template<class Concept2, class Tag2>
2043     any(const any<Concept2, Tag2&>& other
2044 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2045         , typename ::boost::disable_if<
2046             ::boost::mpl::or_<
2047                 ::boost::is_same<Concept, Concept2>,
2048                 ::boost::is_const<Tag2>
2049             >
2050         >::type* = 0
2051 #endif
2052         )
2053       : data(::boost::type_erasure::detail::access::data(other)),
2054         table(
2055             ::boost::type_erasure::detail::access::table(other),
2056             ::boost::mpl::map1<
2057                 ::boost::mpl::pair<
2058                     T,
2059                     Tag2
2060                 >
2061             >())
2062     {}
2063     /**
2064      * Constructs an @ref any from another @ref any.
2065      *
2066      * \param other The object to bind the reference to.
2067      *
2068      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
2069      * \pre After substituting @c T for @c Tag2, the requirements of
2070      *      @c Concept2 must be a superset of the requirements of
2071      *      @c Concept.
2072      *
2073      * \throws std::bad_alloc
2074      */
2075     template<class Concept2, class Tag2>
2076     any(any<Concept2, Tag2>& other
2077 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2078         , typename ::boost::disable_if<
2079             ::boost::mpl::or_<
2080                 ::boost::is_same<Concept, Concept2>,
2081                 ::boost::is_const<typename ::boost::remove_reference<Tag2>::type>
2082             >
2083         >::type* = 0
2084 #endif
2085         )
2086       : data(::boost::type_erasure::detail::access::data(other)),
2087         table(
2088             ::boost::type_erasure::detail::access::table(other),
2089             ::boost::mpl::map1<
2090                 ::boost::mpl::pair<
2091                     T,
2092                     typename ::boost::remove_reference<Tag2>::type
2093                 >
2094             >())
2095     {}
2096     /**
2097      * Constructs an @ref any from another reference.
2098      *
2099      * \param other The reference to copy.
2100      * \param binding Specifies the mapping between the two concepts.
2101      *
2102      * \pre @c Map must be an MPL map with keys for all the non-deduced
2103      *      placeholders used by @c Concept and values for the corresponding
2104      *      placeholders in @c Concept2.
2105      * \pre After substituting placeholders according to @c Map, the
2106      *      requirements of @c Concept2 must be a superset of the
2107      *      requirements of @c Concept.
2108      *
2109      * \throws std::bad_alloc
2110      */
2111     template<class Concept2, class Tag2, class Map>
2112     any(const any<Concept2, Tag2&>& other, const static_binding<Map>& binding_arg
2113 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2114         , typename ::boost::disable_if< ::boost::is_const<Tag2> >::type* = 0
2115 #endif
2116         )
2117       : data(::boost::type_erasure::detail::access::data(other)),
2118         table(::boost::type_erasure::detail::access::table(other), binding_arg)
2119     {}
2120     /**
2121      * Constructs an @ref any from another @ref any.
2122      *
2123      * \param other The object to bind the reference to.
2124      * \param binding Specifies the mapping between the two concepts.
2125      *
2126      * \pre @c Map must be an MPL map with keys for all the non-deduced
2127      *      placeholders used by @c Concept and values for the corresponding
2128      *      placeholders in @c Concept2.
2129      * \pre After substituting placeholders according to @c Map, the
2130      *      requirements of @c Concept2 must be a superset of the
2131      *      requirements of @c Concept.
2132      *
2133      * \throws std::bad_alloc
2134      */
2135     template<class Concept2, class Tag2, class Map>
2136     any(any<Concept2, Tag2>& other, const static_binding<Map>& binding_arg
2137 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2138         , typename ::boost::disable_if<
2139             ::boost::is_const<typename ::boost::remove_reference<Tag2>::type>
2140         >::type* = 0
2141 #endif
2142         )
2143       : data(::boost::type_erasure::detail::access::data(other)),
2144         table(::boost::type_erasure::detail::access::table(other), binding_arg)
2145     {}
2146     /**
2147      * Constructs an @ref any from another reference.
2148      *
2149      * \param other The reference to copy.
2150      * \param binding Specifies the bindings of placeholders to actual types.
2151      *
2152      * \pre The type stored in @c other must match the type expected by
2153      *      @c binding.
2154      *
2155      * \post binding_of(*this) == @c binding
2156      *
2157      * \throws Nothing.
2158      */
2159     template<class Concept2, class Tag2>
2160     any(const any<Concept2, Tag2&>& other, const binding<Concept>& binding_arg
2161 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2162         , typename ::boost::disable_if<
2163             ::boost::is_const<Tag2>
2164         >::type* = 0
2165 #endif
2166         )
2167       : data(::boost::type_erasure::detail::access::data(other)),
2168         table(binding_arg)
2169     {}
2170     /**
2171      * Constructs an @ref any from another @ref any.
2172      *
2173      * \param other The object to bind the reference to.
2174      * \param binding Specifies the bindings of placeholders to actual types.
2175      *
2176      * \pre The type stored in @c other must match the type expected by
2177      *      @c binding.
2178      *
2179      * \post binding_of(*this) == @c binding
2180      *
2181      * \throws Nothing.
2182      */
2183     template<class Concept2, class Tag2>
2184     any(any<Concept2, Tag2>& other, const binding<Concept>& binding_arg
2185 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2186         , typename ::boost::disable_if<
2187             ::boost::is_const<typename ::boost::remove_reference<Tag2>::type>
2188         >::type* = 0
2189 #endif
2190         )
2191       : data(::boost::type_erasure::detail::access::data(other)),
2192         table(binding_arg)
2193     {}
2194     
2195     /** INTERNAL ONLY */
2196     any& operator=(const any& other)
2197     {
2198         _boost_type_erasure_resolve_assign(other);
2199         return *this;
2200     }
2201     
2202     /** INTERNAL ONLY */
2203     any& operator=(any& other)
2204     {
2205         _boost_type_erasure_resolve_assign(other);
2206         return *this;
2207     }
2208     
2209 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
2210     /** INTERNAL ONLY */
2211     any& operator=(any&& other)
2212     {
2213         _boost_type_erasure_resolve_assign(std::move(other));
2214         return *this;
2215     }
2216     /**
2217      * Assigns to an @ref any.
2218      *
2219      * If an appropriate overload of @ref assignable is not available
2220      * and @ref relaxed is in @c Concept, falls back on
2221      * constructing from @c other.
2222      *
2223      * \throws Whatever the assignment operator of the contained
2224      *         type throws.  When falling back on construction,
2225      *         can only throw @c std::bad_alloc if @c U is an @ref any
2226      *         that uses a different @c Concept.  In this case assignment
2227      *         provides the strong exception guarantee.  When
2228      *         calling the assignment operator of the contained type,
2229      *         the exception guarantee is whatever the contained type provides.
2230      */
2231     template<class U>
2232     any& operator=(U&& other)
2233     {
2234         _boost_type_erasure_resolve_assign(std::forward<U>(other));
2235         return *this;
2236     }
2237 #else
2238     template<class U>
2239     any& operator=(U& other)
2240     {
2241         _boost_type_erasure_resolve_assign(other);
2242         return *this;
2243     }
2244     
2245     template<class U>
2246     any& operator=(const U& other)
2247     {
2248         _boost_type_erasure_resolve_assign(other);
2249         return *this;
2250     }
2251 #endif
2252     
2253 #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
2254     /** INTERNAL ONLY */
2255     operator param<Concept, T&>() const { return param<Concept, T&>(data, table); }
2256 #endif
2257 private:
2258 
2259     /** INTERNAL ONLY */
2260     void _boost_type_erasure_swap(any& other)
2261     {
2262         ::std::swap(data, other.data);
2263         ::std::swap(table, other.table);
2264     }
2265 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
2266     /** INTERNAL ONLY */
2267     template<class Other>
2268     void _boost_type_erasure_resolve_assign(Other&& other)
2269     {
2270         _boost_type_erasure_assign_impl(
2271             std::forward<Other>(other),
2272             false? this->_boost_type_erasure_deduce_assign(
2273                 ::boost::type_erasure::detail::make_fallback(
2274                     std::forward<Other>(other),
2275                     ::boost::mpl::bool_<
2276                     sizeof(
2277                         ::boost::type_erasure::detail::check_overload(
2278                             ::boost::declval<any&>().
2279                             _boost_type_erasure_deduce_assign(std::forward<Other>(other))
2280                         )
2281                         ) == sizeof(::boost::type_erasure::detail::yes)
2282                     >()
2283                 )
2284             ) : 0,
2285             ::boost::mpl::and_<
2286                 ::boost::type_erasure::is_relaxed<Concept>,
2287                 ::boost::is_convertible<Other, any>
2288 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1900))
2289               , ::boost::mpl::not_<
2290                     ::boost::type_erasure::detail::is_rvalue_for_any<Other>
2291                 >
2292 #endif
2293             >()
2294         );
2295     }
2296     /** INTERNAL ONLY */
2297     template<class Other, class U>
2298     void _boost_type_erasure_assign_impl(
2299         Other&& other,
2300         const assignable<T, U>*,
2301         ::boost::mpl::false_)
2302     {
2303         ::boost::type_erasure::call(assignable<T, U>(), *this, std::forward<Other>(other));
2304     }
2305     /** INTERNAL ONLY */
2306     template<class Other, class U>
2307     void _boost_type_erasure_assign_impl(
2308         Other&& other,
2309         const assignable<T, U>*,
2310         ::boost::mpl::true_)
2311     {
2312         if(::boost::type_erasure::check_match(assignable<T, U>(), *this, other)) {
2313             ::boost::type_erasure::unchecked_call(assignable<T, U>(), *this, std::forward<Other>(other));
2314         } else {
2315             any temp(std::forward<Other>(other));
2316             _boost_type_erasure_swap(temp);
2317         }
2318     }
2319     /** INTERNAL ONLY */
2320     template<class Other>
2321     void _boost_type_erasure_assign_impl(
2322         Other&& other,
2323         const void*,
2324         ::boost::mpl::true_)
2325     {
2326         any temp(std::forward<Other>(other));
2327         _boost_type_erasure_swap(temp);
2328     }
2329 #else
2330     /** INTERNAL ONLY */
2331     template<class Other>
2332     void _boost_type_erasure_resolve_assign(Other& other)
2333     {
2334         _boost_type_erasure_assign_impl(
2335             other,
2336             false? this->_boost_type_erasure_deduce_assign(
2337                 ::boost::type_erasure::detail::make_fallback(
2338                     other,
2339                     ::boost::mpl::bool_<
2340                         sizeof(
2341                             ::boost::type_erasure::detail::check_overload(
2342                                 ::boost::declval<any&>().
2343                                     _boost_type_erasure_deduce_assign(other)
2344                             )
2345                         ) == sizeof(::boost::type_erasure::detail::yes)
2346                     >()
2347                 )
2348             ) : 0,
2349             ::boost::mpl::and_<
2350                 ::boost::type_erasure::is_relaxed<Concept>,
2351                 ::boost::is_convertible<Other&, any>
2352             >()
2353         );
2354     }
2355     /** INTERNAL ONLY */
2356     template<class Other, class U>
2357     void _boost_type_erasure_assign_impl(
2358         Other& other,
2359         const assignable<T, U>*,
2360         ::boost::mpl::false_)
2361     {
2362         ::boost::type_erasure::call(assignable<T, U>(), *this, other);
2363     }
2364     /** INTERNAL ONLY */
2365     template<class Other, class U>
2366     void _boost_type_erasure_assign_impl(
2367         Other& other,
2368         const assignable<T, U>*,
2369         ::boost::mpl::true_)
2370     {
2371         if(::boost::type_erasure::check_match(assignable<T, U>(), *this, other)) {
2372             ::boost::type_erasure::unchecked_call(assignable<T, U>(), *this, other);
2373         } else {
2374             any temp(other);
2375             _boost_type_erasure_swap(temp);
2376         }
2377     }
2378     /** INTERNAL ONLY */
2379     template<class Other>
2380     void _boost_type_erasure_assign_impl(
2381         Other& other,
2382         const void*,
2383         ::boost::mpl::true_)
2384     {
2385         any temp(other);
2386         _boost_type_erasure_swap(temp);
2387     }
2388 #endif
2389 
2390     friend struct ::boost::type_erasure::detail::access;
2391     ::boost::type_erasure::detail::storage data;
2392     table_type table;
2393 };
2394 
2395 #ifdef BOOST_MSVC
2396 #pragma warning(pop)
2397 #endif
2398 
2399 template<class Concept, class T>
2400 class any<Concept, const T&> :
2401     public ::boost::type_erasure::detail::compute_bases<
2402         ::boost::type_erasure::any<Concept, const T&>,
2403         Concept,
2404         T
2405     >::type
2406 {
2407     typedef ::boost::type_erasure::binding<Concept> table_type;
2408 public:
2409     /** INTERNAL ONLY */
2410     typedef Concept _boost_type_erasure_concept_type;
2411     /** INTERNAL ONLY */
2412     any(const ::boost::type_erasure::detail::storage& data_arg,
2413         const table_type& table_arg)
2414       : data(data_arg),
2415         table(table_arg)
2416     {}
2417     /**
2418      * Constructs an @ref any from a reference.
2419      *
2420      * \param arg The object to bind the reference to.
2421      *
2422      * \pre @c U is a model of @c Concept.
2423      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
2424      *
2425      * \throws Nothing.
2426      */
2427     template<class U>
2428     any(const U& arg)
2429       : table((
2430             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
2431             ::boost::type_erasure::make_binding<
2432                 ::boost::mpl::map1< ::boost::mpl::pair<T, U> >
2433             >()
2434         ))
2435     {
2436         data.data = const_cast<void*>(static_cast<const void*>(::boost::addressof(arg)));
2437     }
2438     /**
2439      * Constructs an @ref any from a reference.
2440      *
2441      * \param arg The object to bind the reference to.
2442      * \param binding Specifies the actual types that
2443      *        all the placeholders should bind to.
2444      *
2445      * \pre @c U is a model of @c Concept.
2446      * \pre @c Map is an MPL map with an entry for every
2447      *         non-deduced placeholder referred to by @c Concept.
2448      *
2449      * \throws Nothing.
2450      */
2451     template<class U, class Map>
2452     any(const U& arg, const static_binding<Map>& binding_arg)
2453       : table((
2454             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
2455             binding_arg
2456         ))
2457     {
2458         BOOST_MPL_ASSERT((::boost::is_same<
2459             typename ::boost::mpl::at<Map, T>::type, U>));
2460         data.data = const_cast<void*>(static_cast<const void*>(::boost::addressof(arg)));
2461     }
2462     /**
2463      * Constructs an @ref any from another @ref any.
2464      *
2465      * \param other The reference to copy.
2466      *
2467      * \throws Nothing.
2468      */
2469     any(const any& other)
2470       : data(other.data),
2471         table(other.table)
2472     {}
2473     /**
2474      * Constructs an @ref any from another @ref any.
2475      *
2476      * \param other The reference to copy.
2477      *
2478      * \throws Nothing.
2479      */
2480     any(const any<Concept, T&>& other)
2481       : data(::boost::type_erasure::detail::access::data(other)),
2482         table(::boost::type_erasure::detail::access::table(other))
2483     {}
2484     /**
2485      * Constructs an @ref any from another @ref any.
2486      *
2487      * \param other The object to bind the reference to.
2488      *
2489      * \throws Nothing.
2490      */
2491     any(const any<Concept, T>& other)
2492       : data(::boost::type_erasure::detail::access::data(other)),
2493         table(::boost::type_erasure::detail::access::table(other))
2494     {}
2495 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
2496     /**
2497      * Constructs an @ref any from another @ref any.
2498      *
2499      * \param other The object to bind the reference to.
2500      *
2501      * \throws Nothing.
2502      */
2503     any(const any<Concept, T&&>& other)
2504       : data(::boost::type_erasure::detail::access::data(other)),
2505         table(::boost::type_erasure::detail::access::table(other))
2506     {}
2507 #endif
2508     /**
2509      * Constructs an @ref any from another @ref any.
2510      *
2511      * \param other The object to bind the reference to.
2512      *
2513      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
2514      * \pre After substituting @c T for @c Tag2, the requirements of
2515      *      @c Concept2 must be a superset of the requirements of
2516      *      @c Concept.
2517      *
2518      * \throws std::bad_alloc
2519      */
2520     template<class Concept2, class Tag2>
2521     any(const any<Concept2, Tag2>& other
2522 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2523         , typename ::boost::disable_if< ::boost::is_same<Concept, Concept2> >::type* = 0
2524 #endif
2525         )
2526       : data(::boost::type_erasure::detail::access::data(other)),
2527         table(
2528             ::boost::type_erasure::detail::access::table(other),
2529             ::boost::mpl::map1<
2530                 ::boost::mpl::pair<
2531                     T,
2532                     typename ::boost::remove_const<
2533                         typename ::boost::remove_reference<Tag2>::type
2534                     >::type
2535                 >
2536             >())
2537     {}
2538     /**
2539      * Constructs an @ref any from another @ref any.
2540      *
2541      * \param other The object to bind the reference to.
2542      * \param binding Specifies the mapping between the two concepts.
2543      *
2544      * \pre @c Map must be an MPL map with keys for all the non-deduced
2545      *      placeholders used by @c Concept and values for the corresponding
2546      *      placeholders in @c Concept2.
2547      * \pre After substituting placeholders according to @c Map, the
2548      *      requirements of @c Concept2 must be a superset of the
2549      *      requirements of @c Concept.
2550      *
2551      * \throws std::bad_alloc
2552      */
2553     template<class Concept2, class Tag2, class Map>
2554     any(const any<Concept2, Tag2>& other, const static_binding<Map>& binding_arg)
2555       : data(::boost::type_erasure::detail::access::data(other)),
2556         table(::boost::type_erasure::detail::access::table(other), binding_arg)
2557     {}
2558     /**
2559      * Constructs an @ref any from another @ref any.
2560      *
2561      * \param other The object to bind the reference to.
2562      * \param binding Specifies the bindings of placeholders to actual types.
2563      *
2564      * \pre The type stored in @c other must match the type expected by
2565      *      @c binding.
2566      *
2567      * \post binding_of(*this) == @c binding
2568      *
2569      * \throws Nothing.
2570      */
2571     template<class Concept2, class Tag2>
2572     any(const any<Concept2, Tag2>& other, const binding<Concept>& binding_arg)
2573       : data(::boost::type_erasure::detail::access::data(other)),
2574         table(binding_arg)
2575     {}
2576     
2577     
2578     /**
2579      * Assigns to an @ref any.
2580      *
2581      * \pre @ref relaxed is in @c Concept.
2582      *
2583      * \throws Nothing.
2584      */
2585     any& operator=(const any& other)
2586     {
2587         BOOST_MPL_ASSERT((::boost::type_erasure::is_relaxed<Concept>));
2588         any temp(other);
2589         _boost_type_erasure_swap(temp);
2590         return *this;
2591     }
2592     /**
2593      * Assigns to an @ref any.
2594      *
2595      * \pre @ref relaxed is in @c Concept.
2596      *
2597      * \throws std::bad_alloc.  Provides the strong exception guarantee.
2598      */
2599     template<class U>
2600     any& operator=(const U& other)
2601     {
2602         BOOST_MPL_ASSERT((::boost::type_erasure::is_relaxed<Concept>));
2603         any temp(other);
2604         _boost_type_erasure_swap(temp);
2605         return *this;
2606     }
2607     
2608 #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
2609     /** INTERNAL ONLY */
2610     operator param<Concept, const T&>() const { return param<Concept, const T&>(data, table); }
2611 #endif
2612 private:
2613     /** INTERNAL ONLY */
2614     void _boost_type_erasure_swap(any& other)
2615     {
2616         ::std::swap(data, other.data);
2617         ::std::swap(table, other.table);
2618     }
2619     friend struct ::boost::type_erasure::detail::access;
2620     ::boost::type_erasure::detail::storage data;
2621     table_type table;
2622 };
2623 
2624 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
2625 
2626 template<class Concept, class T>
2627 class any<Concept, T&&> :
2628     public ::boost::type_erasure::detail::compute_bases<
2629         ::boost::type_erasure::any<Concept, T&&>,
2630         Concept,
2631         T
2632     >::type
2633 {
2634     typedef ::boost::type_erasure::binding<Concept> table_type;
2635 public:
2636     /** INTERNAL ONLY */
2637     typedef Concept _boost_type_erasure_concept_type;
2638     /** INTERNAL ONLY */
2639     any(const ::boost::type_erasure::detail::storage& data_arg,
2640         const table_type& table_arg)
2641       : data(data_arg),
2642         table(table_arg)
2643     {}
2644     /**
2645      * Constructs an @ref any from a reference.
2646      *
2647      * \param arg The object to bind the reference to.
2648      *
2649      * \pre @c U is a model of @c Concept.
2650      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
2651      *
2652      * \throws Nothing.
2653      */
2654     template<class U>
2655     any(U&& arg
2656 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2657         ,  typename ::boost::disable_if<
2658             ::boost::mpl::or_<
2659                 ::boost::is_reference<U>,
2660                 ::boost::is_const<U>,
2661                 ::boost::type_erasure::detail::is_any<U>
2662             >
2663         >::type* = 0
2664 #endif
2665         )
2666       : table((
2667             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
2668             ::boost::type_erasure::make_binding<
2669                 ::boost::mpl::map1< ::boost::mpl::pair<T, U> >
2670             >()
2671         ))
2672     {
2673         data.data = ::boost::addressof(arg);
2674     }
2675     /**
2676      * Constructs an @ref any from a reference.
2677      *
2678      * \param arg The object to bind the reference to.
2679      * \param binding Specifies the actual types that
2680      *        all the placeholders should bind to.
2681      *
2682      * \pre @c U is a model of @c Concept.
2683      * \pre @c Map is an MPL map with an entry for every
2684      *         non-deduced placeholder referred to by @c Concept.
2685      *
2686      * \throws Nothing.
2687      */
2688     template<class U, class Map>
2689     any(U&& arg, const static_binding<Map>& binding_arg)
2690       : table((
2691             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
2692             binding_arg
2693         ))
2694     {
2695         BOOST_MPL_ASSERT((::boost::is_same<
2696             typename ::boost::mpl::at<Map, T>::type, U>));
2697         data.data = ::boost::addressof(arg);
2698     }
2699     /**
2700      * Constructs an @ref any from another rvalue reference.
2701      *
2702      * \param other The reference to copy.
2703      *
2704      * \throws Nothing.
2705      */
2706 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2707     any(any&& other)
2708       : data(other.data),
2709         table(std::move(other.table))
2710     {}
2711     any(const any& other)
2712       : data(other.data),
2713         table(other.table)
2714     {}
2715 #endif
2716     /**
2717      * Constructs an @ref any from another @ref any.
2718      *
2719      * \param other The object to bind the reference to.
2720      *
2721      * \throws Nothing.
2722      */
2723     any(any<Concept, T>&& other)
2724       : data(::boost::type_erasure::detail::access::data(other)),
2725         table(std::move(::boost::type_erasure::detail::access::table(other)))
2726     {}
2727     /**
2728      * Constructs an @ref any from another rvalue reference.
2729      *
2730      * \param other The reference to copy.
2731      *
2732      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
2733      * \pre After substituting @c T for @c Tag2, the requirements of
2734      *      @c Concept2 must be a superset of the requirements of
2735      *      @c Concept.
2736      *
2737      * \throws std::bad_alloc
2738      */
2739     template<class Concept2, class Tag2>
2740     any(any<Concept2, Tag2&&>&& other
2741 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2742         , typename ::boost::disable_if<
2743             ::boost::mpl::or_<
2744                 ::boost::is_reference<Tag2>,
2745                 ::boost::is_same<Concept, Concept2>,
2746                 ::boost::is_const<Tag2>
2747             >
2748         >::type* = 0
2749 #endif
2750         )
2751       : data(::boost::type_erasure::detail::access::data(other)),
2752         table(
2753             std::move(::boost::type_erasure::detail::access::table(other)),
2754             ::boost::mpl::map1<
2755                 ::boost::mpl::pair<
2756                     T,
2757                     Tag2
2758                 >
2759             >())
2760     {}
2761     /**
2762      * Constructs an @ref any from another @ref any.
2763      *
2764      * \param other The object to bind the reference to.
2765      *
2766      * \pre @c Concept must not refer to any non-deduced placeholder besides @c T.
2767      * \pre After substituting @c T for @c Tag2, the requirements of
2768      *      @c Concept2 must be a superset of the requirements of
2769      *      @c Concept.
2770      *
2771      * \throws std::bad_alloc
2772      */
2773     template<class Concept2, class Tag2>
2774     any(any<Concept2, Tag2>&& other
2775 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2776         , typename ::boost::disable_if<
2777             ::boost::mpl::or_<
2778                 ::boost::is_same<Concept, Concept2>,
2779                 ::boost::is_const<typename ::boost::remove_reference<Tag2>::type>
2780             >
2781         >::type* = 0
2782 #endif
2783         )
2784       : data(::boost::type_erasure::detail::access::data(other)),
2785         table(
2786             std::move(::boost::type_erasure::detail::access::table(other)),
2787             ::boost::mpl::map1<
2788                 ::boost::mpl::pair<
2789                     T,
2790                     typename ::boost::remove_reference<Tag2>::type
2791                 >
2792             >())
2793     {}
2794     /**
2795      * Constructs an @ref any from another reference.
2796      *
2797      * \param other The reference to copy.
2798      * \param binding Specifies the mapping between the two concepts.
2799      *
2800      * \pre @c Map must be an MPL map with keys for all the non-deduced
2801      *      placeholders used by @c Concept and values for the corresponding
2802      *      placeholders in @c Concept2.
2803      * \pre After substituting placeholders according to @c Map, the
2804      *      requirements of @c Concept2 must be a superset of the
2805      *      requirements of @c Concept.
2806      *
2807      * \throws std::bad_alloc
2808      */
2809     template<class Concept2, class Tag2, class Map>
2810     any(const any<Concept2, Tag2&&>& other, const static_binding<Map>& binding_arg
2811 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2812         , typename ::boost::disable_if< ::boost::is_const<Tag2> >::type* = 0
2813 #endif
2814         )
2815       : data(::boost::type_erasure::detail::access::data(other)),
2816         table(std::move(::boost::type_erasure::detail::access::table(other)), binding_arg)
2817     {}
2818     /**
2819      * Constructs an @ref any from another @ref any.
2820      *
2821      * \param other The object to bind the reference to.
2822      * \param binding Specifies the mapping between the two concepts.
2823      *
2824      * \pre @c Map must be an MPL map with keys for all the non-deduced
2825      *      placeholders used by @c Concept and values for the corresponding
2826      *      placeholders in @c Concept2.
2827      * \pre After substituting placeholders according to @c Map, the
2828      *      requirements of @c Concept2 must be a superset of the
2829      *      requirements of @c Concept.
2830      *
2831      * \throws std::bad_alloc
2832      */
2833     template<class Concept2, class Tag2, class Map>
2834     any(any<Concept2, Tag2>&& other, const static_binding<Map>& binding_arg
2835 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2836         , typename ::boost::disable_if<
2837             ::boost::is_const<typename ::boost::remove_reference<Tag2>::type>
2838         >::type* = 0
2839 #endif
2840         )
2841       : data(::boost::type_erasure::detail::access::data(other)),
2842         table(::boost::type_erasure::detail::access::table(other), binding_arg)
2843     {}
2844     /**
2845      * Constructs an @ref any from another rvalue reference.
2846      *
2847      * \param other The reference to copy.
2848      * \param binding Specifies the bindings of placeholders to actual types.
2849      *
2850      * \pre The type stored in @c other must match the type expected by
2851      *      @c binding.
2852      *
2853      * \post binding_of(*this) == @c binding
2854      *
2855      * \throws Nothing.
2856      */
2857     template<class Concept2, class Tag2>
2858     any(const any<Concept2, Tag2&&>& other, const binding<Concept>& binding_arg
2859 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2860         , typename ::boost::disable_if<
2861             ::boost::is_const<Tag2>
2862         >::type* = 0
2863 #endif
2864         )
2865       : data(::boost::type_erasure::detail::access::data(other)),
2866         table(binding_arg)
2867     {}
2868     /**
2869      * Constructs an @ref any from another @ref any.
2870      *
2871      * \param other The object to bind the reference to.
2872      * \param binding Specifies the bindings of placeholders to actual types.
2873      *
2874      * \pre The type stored in @c other must match the type expected by
2875      *      @c binding.
2876      *
2877      * \post binding_of(*this) == @c binding
2878      *
2879      * \throws Nothing.
2880      */
2881     template<class Concept2, class Tag2>
2882     any(any<Concept2, Tag2>&& other, const binding<Concept>& binding_arg
2883 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
2884         , typename ::boost::disable_if<
2885             ::boost::is_const<typename ::boost::remove_reference<Tag2>::type>
2886         >::type* = 0
2887 #endif
2888         )
2889       : data(::boost::type_erasure::detail::access::data(other)),
2890         table(binding_arg)
2891     {}
2892     
2893     /** INTERNAL ONLY */
2894     any& operator=(const any& other)
2895     {
2896         _boost_type_erasure_resolve_assign(other);
2897         return *this;
2898     }
2899     
2900     /**
2901      * Assigns to an @ref any.
2902      *
2903      * If an appropriate overload of @ref assignable is not available
2904      * and @ref relaxed is in @c Concept, falls back on
2905      * constructing from @c other.
2906      *
2907      * \throws Whatever the assignment operator of the contained
2908      *         type throws.  When falling back on construction,
2909      *         can only throw @c std::bad_alloc if @c U is an @ref any
2910      *         that uses a different @c Concept.  In this case assignment
2911      *         provides the strong exception guarantee.  When
2912      *         calling the assignment operator of the contained type,
2913      *         the exception guarantee is whatever the contained type provides.
2914      */
2915     template<class U>
2916     any& operator=(U&& other)
2917     {
2918         _boost_type_erasure_resolve_assign(std::forward<U>(other));
2919         return *this;
2920     }
2921     
2922 #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
2923     /** INTERNAL ONLY */
2924     operator param<Concept, T&&>() const { return param<Concept, T&&>(data, table); }
2925 #endif
2926 private:
2927 
2928     /** INTERNAL ONLY */
2929     void _boost_type_erasure_swap(any& other)
2930     {
2931         ::std::swap(data, other.data);
2932         ::std::swap(table, other.table);
2933     }
2934     /** INTERNAL ONLY */
2935     template<class Other>
2936     void _boost_type_erasure_resolve_assign(Other&& other)
2937     {
2938         _boost_type_erasure_assign_impl(
2939             std::forward<Other>(other),
2940             false? this->_boost_type_erasure_deduce_assign(
2941                 ::boost::type_erasure::detail::make_fallback(
2942                     std::forward<Other>(other),
2943                     ::boost::mpl::bool_<
2944                     sizeof(
2945                         ::boost::type_erasure::detail::check_overload(
2946                             ::boost::declval<any&>().
2947                             _boost_type_erasure_deduce_assign(std::forward<Other>(other))
2948                         )
2949                         ) == sizeof(::boost::type_erasure::detail::yes)
2950                     >()
2951                 )
2952             ) : 0,
2953             ::boost::mpl::and_<
2954                 ::boost::type_erasure::is_relaxed<Concept>,
2955                 ::boost::is_convertible<Other, any>
2956             >()
2957         );
2958     }
2959     /** INTERNAL ONLY */
2960     template<class Other, class U>
2961     void _boost_type_erasure_assign_impl(
2962         Other&& other,
2963         const assignable<T, U>*,
2964         ::boost::mpl::false_)
2965     {
2966         ::boost::type_erasure::call(
2967             assignable<T, U>(),
2968             // lose rvalueness of this
2969             ::boost::type_erasure::param<Concept, T&>(data, table),
2970             std::forward<Other>(other));
2971     }
2972     /** INTERNAL ONLY */
2973     template<class Other, class U>
2974     void _boost_type_erasure_assign_impl(
2975         Other&& other,
2976         const assignable<T, U>*,
2977         ::boost::mpl::true_)
2978     {
2979         if(::boost::type_erasure::check_match(assignable<T, U>(), *this, other)) {
2980             ::boost::type_erasure::unchecked_call(
2981                 assignable<T, U>(),
2982                 // lose rvalueness of this
2983                 ::boost::type_erasure::param<Concept, T&>(data, table),
2984                 std::forward<Other>(other));
2985         } else {
2986             any temp(std::forward<Other>(other));
2987             _boost_type_erasure_swap(temp);
2988         }
2989     }
2990     /** INTERNAL ONLY */
2991     template<class Other>
2992     void _boost_type_erasure_assign_impl(
2993         Other&& other,
2994         const void*,
2995         ::boost::mpl::true_)
2996     {
2997         any temp(std::forward<Other>(other));
2998         _boost_type_erasure_swap(temp);
2999     }
3000 
3001     friend struct ::boost::type_erasure::detail::access;
3002     ::boost::type_erasure::detail::storage data;
3003     table_type table;
3004 };
3005 
3006 #endif
3007 
3008 #ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES
3009 template<class Concept, class T>
3010 using any_ref = any<Concept, T&>;
3011 template<class Concept, class T>
3012 using any_cref = any<Concept, const T&>;
3013 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
3014 template<class Concept, class T>
3015 using any_rvref = any<Concept, T&&>;
3016 #endif
3017 #endif
3018 
3019 }
3020 }
3021 
3022 #endif