File indexing completed on 2024-11-15 09:32:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
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)
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
0149
0150
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
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
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
0407 any_constructor_impl()
0408 {
0409 BOOST_MPL_ASSERT((::boost::type_erasure::is_relaxed<Concept>));
0410 _boost_type_erasure_data.data = 0;
0411 }
0412
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
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
0513
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
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
0596
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
0655
0656
0657
0658
0659
0660
0661
0662
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
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
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
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
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
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
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
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
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
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
0821
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
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
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855 any(const any& other)
0856 : table(other.table),
0857 data(::boost::type_erasure::call(constructible<T(const T&)>(), other))
0858 {}
0859
0860
0861
0862
0863
0864
0865
0866
0867
0868
0869
0870
0871
0872
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
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
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
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
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
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975 template<class... U>
0976 explicit any(U&&... arg);
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989
0990
0991
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
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
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
1377
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
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
1521 any& operator=(const any& other)
1522 {
1523 _boost_type_erasure_resolve_assign(other);
1524 return *this;
1525 }
1526
1527 any& operator=(any& other)
1528 {
1529 _boost_type_erasure_resolve_assign(other);
1530 return *this;
1531 }
1532
1533 #endif
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
1551 any& operator=(any&& other)
1552 {
1553 _boost_type_erasure_resolve_assign(std::move(other));
1554 return *this;
1555 }
1556 #endif
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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))
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
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
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
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
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
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
1921
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
1941 typedef Concept _boost_type_erasure_concept_type;
1942
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
1950
1951
1952
1953
1954
1955
1956
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
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
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
2004
2005
2006
2007
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
2021
2022
2023
2024
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
2032
2033
2034
2035
2036
2037
2038
2039
2040
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
2065
2066
2067
2068
2069
2070
2071
2072
2073
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
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
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
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
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
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
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
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
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
2196 any& operator=(const any& other)
2197 {
2198 _boost_type_erasure_resolve_assign(other);
2199 return *this;
2200 }
2201
2202
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
2211 any& operator=(any&& other)
2212 {
2213 _boost_type_erasure_resolve_assign(std::move(other));
2214 return *this;
2215 }
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
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
2255 operator param<Concept, T&>() const { return param<Concept, T&>(data, table); }
2256 #endif
2257 private:
2258
2259
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
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
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
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
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
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
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
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
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
2410 typedef Concept _boost_type_erasure_concept_type;
2411
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
2419
2420
2421
2422
2423
2424
2425
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
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
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
2464
2465
2466
2467
2468
2469 any(const any& other)
2470 : data(other.data),
2471 table(other.table)
2472 {}
2473
2474
2475
2476
2477
2478
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
2486
2487
2488
2489
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
2498
2499
2500
2501
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
2510
2511
2512
2513
2514
2515
2516
2517
2518
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
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
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
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
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
2580
2581
2582
2583
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
2594
2595
2596
2597
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
2610 operator param<Concept, const T&>() const { return param<Concept, const T&>(data, table); }
2611 #endif
2612 private:
2613
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
2637 typedef Concept _boost_type_erasure_concept_type;
2638
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
2646
2647
2648
2649
2650
2651
2652
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
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
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
2701
2702
2703
2704
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
2718
2719
2720
2721
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
2729
2730
2731
2732
2733
2734
2735
2736
2737
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
2763
2764
2765
2766
2767
2768
2769
2770
2771
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
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
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
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
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
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
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
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
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
2894 any& operator=(const any& other)
2895 {
2896 _boost_type_erasure_resolve_assign(other);
2897 return *this;
2898 }
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
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
2924 operator param<Concept, T&&>() const { return param<Concept, T&&>(data, table); }
2925 #endif
2926 private:
2927
2928
2929 void _boost_type_erasure_swap(any& other)
2930 {
2931 ::std::swap(data, other.data);
2932 ::std::swap(table, other.table);
2933 }
2934
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
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
2969 ::boost::type_erasure::param<Concept, T&>(data, table),
2970 std::forward<Other>(other));
2971 }
2972
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
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
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