Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83321 - in sandbox/type_erasure: boost/type_erasure boost/type_erasure/detail libs/type_erasure/test
From: steven_at_[hidden]
Date: 2013-03-05 16:27:20


Author: steven_watanabe
Date: 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
New Revision: 83321
URL: http://svn.boost.org/trac/boost/changeset/83321

Log:
Handle rvalue references for construction.
Text files modified:
   sandbox/type_erasure/boost/type_erasure/any.hpp | 404 ++++++++++++++++--
   sandbox/type_erasure/boost/type_erasure/call.hpp | 42 +
   sandbox/type_erasure/boost/type_erasure/constructible.hpp | 16
   sandbox/type_erasure/boost/type_erasure/detail/access.hpp | 18
   sandbox/type_erasure/boost/type_erasure/detail/check_call.hpp | 6
   sandbox/type_erasure/boost/type_erasure/detail/construct.hpp | 92 ++++
   sandbox/type_erasure/libs/type_erasure/test/test_construct.cpp | 852 ++++++++++++++++++++++++++++++++++++---
   7 files changed, 1285 insertions(+), 145 deletions(-)

Modified: sandbox/type_erasure/boost/type_erasure/any.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/any.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/any.hpp 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
@@ -142,6 +142,13 @@
       : table(table_arg),
         data(data_arg)
     {}
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ /** INTERNAL ONLY */
+ any(::boost::type_erasure::detail::storage&& data_arg, const table_type& table_arg)
+ : table(table_arg),
+ data(data_arg)
+ {}
+#endif
     /**
      * Constructs a null @ref any.
      *
@@ -154,6 +161,33 @@
         BOOST_MPL_ASSERT((::boost::type_erasure::is_relaxed<Concept>));
         data.data = 0;
     }
+
+#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+
+ template<class U>
+ any(const U& data_arg)
+ : table((
+ BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
+ ::boost::type_erasure::make_binding<
+ ::boost::mpl::map< ::boost::mpl::pair<T, U> >
+ >()
+ )),
+ data(data_arg)
+ {}
+ template<class U, class Map>
+ any(const U& data_arg, const static_binding<Map>& binding_arg)
+ : table((
+ BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
+ binding_arg
+ )),
+ data(data_arg)
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, U>));
+ }
+
+#else
+
     /**
      * Constructs an @ref any to hold a copy of @c data.
      * The @c Concept will be instantiated with the
@@ -169,14 +203,14 @@
      * constructor of @c U throws.
      */
     template<class U>
- any(const U& data_arg)
+ any(U&& data_arg)
       : table((
- BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
+ BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type),
             ::boost::type_erasure::make_binding<
- ::boost::mpl::map< ::boost::mpl::pair<T, U> >
+ ::boost::mpl::map< ::boost::mpl::pair<T, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type> >
>()
         )),
- data(data_arg)
+ data(std::forward<U>(data_arg))
     {}
     /**
      * Constructs an @ref any to hold a copy of @c data
@@ -196,16 +230,19 @@
      * constructor of @c U throws.
      */
     template<class U, class Map>
- any(const U& data_arg, const static_binding<Map>& binding_arg)
+ any(U&& data_arg, const static_binding<Map>& binding_arg)
       : table((
             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
             binding_arg
         )),
- data(data_arg)
+ data(std::forward<U>(data_arg))
     {
         BOOST_MPL_ASSERT((::boost::is_same<
- typename ::boost::mpl::at<Map, T>::type, U>));
+ typename ::boost::mpl::at<Map, T>::type, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type>));
     }
+
+#endif
+
     // Handle array/function-to-pointer decay
     /** INTERNAL ONLY */
     template<class U>
@@ -383,6 +420,54 @@
     {}
 
 #else
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ any(any&& other)
+ : table(::boost::type_erasure::detail::access::table(other)),
+ data(::boost::type_erasure::call(
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(std::move(other)) : 0
+ ), std::move(other))
+ )
+ {}
+ template<class Concept2, class Tag2>
+ any(any<Concept2, Tag2>& other)
+ : table(
+ ::boost::type_erasure::detail::access::table(other),
+ ::boost::mpl::map<
+ ::boost::mpl::pair<
+ T,
+ typename ::boost::remove_const<
+ typename ::boost::remove_reference<Tag2>::type
+ >::type
+ >
+ >()
+ ),
+ data(::boost::type_erasure::call(
+ ::boost::type_erasure::detail::make(
+ false? other._boost_type_erasure_deduce_constructor(other) : 0
+ ), other)
+ )
+ {}
+ template<class Concept2, class Tag2>
+ any(any<Concept2, Tag2>&& other)
+ : table(
+ ::boost::type_erasure::detail::access::table(other),
+ ::boost::mpl::map<
+ ::boost::mpl::pair<
+ T,
+ typename ::boost::remove_const<
+ typename ::boost::remove_reference<Tag2>::type
+ >::type
+ >
+ >()
+ ),
+ data(::boost::type_erasure::call(
+ ::boost::type_erasure::detail::make(
+ false? other._boost_type_erasure_deduce_constructor(std::move(other)) : 0
+ ), std::move(other))
+ )
+ {}
+#endif
     // construction from a reference
     any(const any<Concept, T&>& other)
       : table(::boost::type_erasure::detail::access::table(other)),
@@ -400,6 +485,16 @@
             ), other)
         )
     {}
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ any(any<Concept, T&>&& other)
+ : table(::boost::type_erasure::detail::access::table(other)),
+ data(::boost::type_erasure::call(
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(other) : 0
+ ), other)
+ )
+ {}
+#endif
     any(const any<Concept, const T&>& other)
       : table(::boost::type_erasure::detail::access::table(other)),
         data(::boost::type_erasure::call(
@@ -416,24 +511,41 @@
             ), other)
         )
     {}
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ any(any<Concept, const T&>&& other)
+ : table(::boost::type_erasure::detail::access::table(other)),
+ data(::boost::type_erasure::call(
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(other) : 0
+ ), other)
+ )
+ {}
+#endif
 
     // disambiguating overloads
     template<class U, class Map>
- any(U& data_arg, static_binding<Map>& binding_arg)
+ any(U* data_arg, static_binding<Map>& binding_arg)
       : table((
             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
             binding_arg
         )),
         data(data_arg)
- {}
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, U*>));
+ }
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
     template<class U, class Map>
- any(U* data_arg, static_binding<Map>& binding_arg)
+ any(U& data_arg, static_binding<Map>& binding_arg)
       : table((
             BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
             binding_arg
         )),
         data(data_arg)
- {}
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, U>));
+ }
     template<class U, class Map>
     any(const U& data_arg, static_binding<Map>& binding_arg)
       : table((
@@ -441,7 +553,10 @@
             binding_arg
         )),
         data(data_arg)
- {}
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, U>));
+ }
     template<class U, class Map>
     any(U& data_arg, const static_binding<Map>& binding_arg)
       : table((
@@ -449,7 +564,46 @@
             binding_arg
         )),
         data(data_arg)
- {}
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, U>));
+ }
+#endif
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ template<class U, class Map>
+ any(U* data_arg, static_binding<Map>&& binding_arg)
+ : table((
+ BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
+ binding_arg
+ )),
+ data(data_arg)
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, U*>));
+ }
+ template<class U, class Map>
+ any(U&& data_arg, static_binding<Map>& binding_arg)
+ : table((
+ BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
+ binding_arg
+ )),
+ data(data_arg)
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type>));
+ }
+ template<class U, class Map>
+ any(U&& data_arg, static_binding<Map>&& binding_arg)
+ : table((
+ BOOST_TYPE_ERASURE_INSTANTIATE(Concept, Map),
+ binding_arg
+ )),
+ data(data_arg)
+ {
+ BOOST_MPL_ASSERT((::boost::is_same<
+ typename ::boost::mpl::at<Map, T>::type, typename ::boost::remove_cv<typename ::boost::remove_reference<U>::type>::type>));
+ }
+#endif
     template<class Concept2, class Tag2, class Map>
     any(any<Concept2, Tag2>& other, static_binding<Map>& binding_arg)
       : table(::boost::type_erasure::detail::access::table(other), binding_arg),
@@ -517,6 +671,119 @@
         )
     {}
 
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ template<class Concept2, class Tag2, class Map>
+ any(any<Concept2, Tag2>& other, static_binding<Map>&& binding_arg)
+ : table(::boost::type_erasure::detail::access::table(other), binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), other)
+ )
+ {}
+ template<class Concept2, class Tag2, class Map>
+ any(const any<Concept2, Tag2>& other, static_binding<Map>&& binding_arg)
+ : table(::boost::type_erasure::detail::access::table(other), binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), other)
+ )
+ {}
+ template<class Concept2, class Tag2, class Map>
+ any(any<Concept2, Tag2>&& other, static_binding<Map>&& binding_arg)
+ : table(::boost::type_erasure::detail::access::table(other), binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), std::move(other))
+ )
+ {}
+ template<class Concept2, class Tag2, class Map>
+ any(any<Concept2, Tag2>&& other, static_binding<Map>& binding_arg)
+ : table(::boost::type_erasure::detail::access::table(other), binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), std::move(other))
+ )
+ {}
+ template<class Concept2, class Tag2, class Map>
+ any(any<Concept2, Tag2>&& other, const static_binding<Map>& binding_arg)
+ : table(::boost::type_erasure::detail::access::table(other), binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), std::move(other))
+ )
+ {}
+ template<class Concept2, class Tag2>
+ any(any<Concept2, Tag2>& other, binding<Concept>&& binding_arg)
+ : table(binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), other)
+ )
+ {}
+ template<class Concept2, class Tag2>
+ any(const any<Concept2, Tag2>& other, binding<Concept>&& binding_arg)
+ : table(binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), other)
+ )
+ {}
+ template<class Concept2, class Tag2>
+ any(any<Concept2, Tag2>&& other, binding<Concept>&& binding_arg)
+ : table(binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), std::move(other))
+ )
+ {}
+ template<class Concept2, class Tag2>
+ any(any<Concept2, Tag2>&& other, binding<Concept>& binding_arg)
+ : table(binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), std::move(other))
+ )
+ {}
+ template<class Concept2, class Tag2>
+ any(any<Concept2, Tag2>&& other, const binding<Concept>& binding_arg)
+ : table(binding_arg),
+ data(::boost::type_erasure::call(
+ constructible<
+ typename ::boost::remove_const<
+ typename boost::remove_reference<Tag2>::type
+ >::type(const typename boost::remove_reference<Tag2>::type&)
+ >(), std::move(other))
+ )
+ {}
+#endif
+
     // One argument is a special case. The argument must be an any
     // and the constructor must be explicit.
     template<class Tag2>
@@ -538,6 +805,18 @@
         )
     {}
 
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ template<class Tag2>
+ explicit any(any<Concept, Tag2>&& other)
+ : table(::boost::type_erasure::detail::access::table(other)),
+ data(::boost::type_erasure::call(
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(std::move(other)) : 0
+ ), std::move(other))
+ )
+ {}
+#endif
+
     explicit any(const binding<Concept>& binding_arg)
       : table(binding_arg),
         data(
@@ -547,92 +826,96 @@
             )
         )
     {}
+ explicit any(binding<Concept>& binding_arg)
+ : table(binding_arg),
+ data(
+ ::boost::type_erasure::call(
+ binding_arg,
+ ::boost::type_erasure::constructible<T()>()
+ )
+ )
+ {}
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+ explicit any(binding<Concept>&& binding_arg)
+ : table(binding_arg),
+ data(
+ ::boost::type_erasure::call(
+ binding_arg,
+ ::boost::type_erasure::constructible<T()>()
+ )
+ )
+ {}
+
+#endif
 
 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 
     template<class R, class... A, class... U>
     const table_type& _boost_type_erasure_extract_table(
         ::boost::type_erasure::constructible<R(A...)>*,
- U&... u)
+ U&&... u)
     {
         return *::boost::type_erasure::detail::extract_table(static_cast<void(*)(A...)>(0), u...);
     }
 
     template<class U0, class U1, class... U>
- any(const U0& u0, const U1& u1, const U&... u)
- : table(
- _boost_type_erasure_extract_table(
- false? this->_boost_type_erasure_deduce_constructor(u0, u1, u...) : 0,
- u0, u1, u...
- )
- ),
- data(
- ::boost::type_erasure::call(
- ::boost::type_erasure::detail::make(
- false? this->_boost_type_erasure_deduce_constructor(u0, u1, u...) : 0
- ),
- u0, u1, u...
- )
- )
- {}
-
- template<class U0, class U1, class... U>
- any(U0& u0, U1& u1, U&... u)
+ any(U0&& u0, U1&& u1, U&&... u)
       : table(
             _boost_type_erasure_extract_table(
- false? this->_boost_type_erasure_deduce_constructor(u0, u1, u...) : 0,
- u0, u1, u...
+ false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...) : 0,
+ std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...
             )
         ),
         data(
             ::boost::type_erasure::call(
                 ::boost::type_erasure::detail::make(
- false? this->_boost_type_erasure_deduce_constructor(u0, u1, u...) : 0
+ false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...) : 0
                 ),
- u0, u1, u...
+ std::forward<U0>(u0), std::forward<U1>(u1), std::forward<U>(u)...
             )
         )
     {}
 
     template<class U0, class... U>
- any(const binding<Concept>& binding_arg, const U0& u0, const U&... u)
+ any(const binding<Concept>& binding_arg, U0&& u0, U&&... u)
       : table(binding_arg),
         data(
             ::boost::type_erasure::call(
                 binding_arg,
                 ::boost::type_erasure::detail::make(
- false? this->_boost_type_erasure_deduce_constructor(u0, u...) : 0
+ false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U>(u)...) : 0
                 ),
- u0, u...
+ std::forward<U0>(u0), std::forward<U>(u)...
             )
         )
     {}
-
+
+ // disambiguate
     template<class U0, class... U>
- any(const binding<Concept>& binding_arg, U0& u0, U&... u)
+ any(binding<Concept>& binding_arg, U0&& u0, U&&... u)
       : table(binding_arg),
         data(
             ::boost::type_erasure::call(
                 binding_arg,
                 ::boost::type_erasure::detail::make(
- false? this->_boost_type_erasure_deduce_constructor(u0, u...) : 0
+ false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U>(u)...) : 0
                 ),
- u0, u...
+ std::forward<U0>(u0), std::forward<U>(u)...
             )
         )
     {}
-
- // disambiguate
     template<class U0, class... U>
- any(binding<Concept>& binding_arg, U0& u0, U&... u)
+ any(binding<Concept>&& binding_arg, U0&& u0, U&&... u)
       : table(binding_arg),
         data(
             ::boost::type_erasure::call(
                 binding_arg,
                 ::boost::type_erasure::detail::make(
- false? this->_boost_type_erasure_deduce_constructor(u0, u...) : 0
+ false? this->_boost_type_erasure_deduce_constructor(std::forward<U0>(u0), std::forward<U>(u)...) : 0
                 ),
- u0, u...
+ std::forward<U0>(u0), std::forward<U>(u)...
             )
         )
     {}
@@ -1350,6 +1633,19 @@
       : data(::boost::type_erasure::detail::access::data(other)),
         table(::boost::type_erasure::detail::access::table(other))
     {}
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ /**
+ * Constructs an @ref any from another @ref any.
+ *
+ * \param other The object to bind the reference to.
+ *
+ * \throws Nothing.
+ */
+ any(const any<Concept, T&&>& other)
+ : data(::boost::type_erasure::detail::access::data(other)),
+ table(::boost::type_erasure::detail::access::table(other))
+ {}
+#endif
     /**
      * Constructs an @ref any from another @ref any.
      *
@@ -1553,6 +1849,10 @@
       : data(other.data),
         table(std::move(other.table))
     {}
+ any(const any& other)
+ : data(other.data),
+ table(other.table)
+ {}
 #endif
     /**
      * Constructs an @ref any from another @ref any.
@@ -1648,7 +1948,7 @@
      * \throws std::bad_alloc
      */
     template<class Concept2, class Tag2, class Map>
- any(any<Concept2, Tag2&&>&& other, const static_binding<Map>& binding_arg
+ any(const any<Concept2, Tag2&&>& other, const static_binding<Map>& binding_arg
 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
         , typename ::boost::disable_if< ::boost::is_const<Tag2> >::type* = 0
 #endif
@@ -1696,7 +1996,7 @@
      * \throws Nothing.
      */
     template<class Concept2, class Tag2>
- any(const any<Concept2, Tag2&&>&& other, const binding<Concept>& binding_arg
+ any(const any<Concept2, Tag2&&>& other, const binding<Concept>& binding_arg
 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
         , typename ::boost::disable_if<
             ::boost::is_const<Tag2>
@@ -1720,7 +2020,7 @@
      * \throws Nothing.
      */
     template<class Concept2, class Tag2>
- any(any<Concept2, Tag2>& other, const binding<Concept>& binding_arg
+ any(any<Concept2, Tag2>&& other, const binding<Concept>& binding_arg
 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
         , typename ::boost::disable_if<
             ::boost::is_const<typename ::boost::remove_reference<Tag2>::type>

Modified: sandbox/type_erasure/boost/type_erasure/call.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/call.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/call.hpp 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
@@ -129,6 +129,20 @@
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
 template<class Concept, class T>
+const ::boost::type_erasure::detail::storage&
+convert_arg(any_base<any<Concept, const T&> >&& arg, boost::mpl::true_)
+{
+ return ::boost::type_erasure::detail::access::data(arg);
+}
+
+template<class Concept, class T>
+::boost::type_erasure::detail::storage&
+convert_arg(any_base<any<Concept, T&> >&& arg, boost::mpl::true_)
+{
+ return ::boost::type_erasure::detail::access::data(arg);
+}
+
+template<class Concept, class T>
 ::boost::type_erasure::detail::storage&&
 convert_arg(any_base<any<Concept, T> >&& arg, boost::mpl::true_)
 {
@@ -144,6 +158,27 @@
 
 template<class Concept, class T>
 ::boost::type_erasure::detail::storage&&
+convert_arg(const any_base<any<Concept, T&&> >& arg, boost::mpl::true_)
+{
+ return ::boost::type_erasure::detail::access::data(arg);
+}
+
+template<class Concept, class T>
+const ::boost::type_erasure::detail::storage&
+convert_arg(param<Concept, const T&>&& arg, boost::mpl::true_)
+{
+ return ::boost::type_erasure::detail::access::data(arg);
+}
+
+template<class Concept, class T>
+::boost::type_erasure::detail::storage&
+convert_arg(param<Concept, T&>&& arg, boost::mpl::true_)
+{
+ return ::boost::type_erasure::detail::access::data(arg);
+}
+
+template<class Concept, class T>
+::boost::type_erasure::detail::storage&&
 convert_arg(param<Concept, T>&& arg, boost::mpl::true_)
 {
     return ::boost::type_erasure::detail::access::data(std::move(arg));
@@ -156,6 +191,13 @@
     return ::boost::type_erasure::detail::access::data(arg);
 }
 
+template<class Concept, class T>
+::boost::type_erasure::detail::storage&&
+convert_arg(const param<Concept, T&&>& arg, boost::mpl::true_)
+{
+ return ::boost::type_erasure::detail::access::data(arg);
+}
+
 template<class T>
 T&& convert_arg(T&& arg, boost::mpl::false_) { return std::forward<T>(arg); }
 

Modified: sandbox/type_erasure/boost/type_erasure/constructible.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/constructible.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/constructible.hpp 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
@@ -60,7 +60,7 @@
 template<class Sig>
 struct constructible {};
 
-#elif !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+#elif !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
 
 template<class R, class... T>
 struct constructible<R(T...)>
@@ -69,7 +69,7 @@
     apply(T... arg)
     {
         ::boost::type_erasure::detail::storage result;
- result.data = new R(arg...);
+ result.data = new R(::std::forward<T>(arg)...);
         return result;
     }
 };
@@ -136,6 +136,13 @@
         BOOST_PP_CAT(T, n) \
>::type
 
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+#define BOOST_TYPE_ERASURE_FORWARD_I(z, n, data) ::std::forward<BOOST_PP_CAT(T, n)>(BOOST_PP_CAT(arg, n))
+#define BOOST_TYPE_ERASURE_FORWARD(n) BOOST_PP_ENUM(n, BOOST_TYPE_ERASURE_FORWARD_I, ~)
+#else
+#define BOOST_TYPE_ERASURE_FORWARD(n) BOOST_PP_ENUM_PARAMS(n, arg)
+#endif
+
 template<class R BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)>
 struct constructible<R(BOOST_PP_ENUM_PARAMS(N, T))>
 {
@@ -143,7 +150,7 @@
     apply(BOOST_PP_ENUM_BINARY_PARAMS(N, T, arg))
     {
         ::boost::type_erasure::detail::storage result;
- result.data = new R(BOOST_PP_ENUM_PARAMS(N, arg));
+ result.data = new R(BOOST_TYPE_ERASURE_FORWARD(N));
         return result;
     }
 };
@@ -186,6 +193,9 @@
 
 }
 
+#undef BOOST_TYPE_ERASURE_FORWARD
+#undef BOOST_TYPE_ERASURE_FORWARD_I
+
 #undef BOOST_TYPE_ERASURE_ARG_DECL
 #undef N
 

Modified: sandbox/type_erasure/boost/type_erasure/detail/access.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/detail/access.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/detail/access.hpp 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
@@ -88,19 +88,25 @@
         return arg._impl.data;
     }
 
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 
     template<class Derived>
     static ::boost::type_erasure::detail::storage&&
     data(::boost::type_erasure::any_base<Derived>&& arg)
     {
- return static_cast<Derived&&>(arg).data;
+ return std::move(static_cast<Derived&>(arg).data);
     }
     template<class Concept, class T>
     static ::boost::type_erasure::detail::storage&&
     data(::boost::type_erasure::any_base< ::boost::type_erasure::any<Concept, T&&> >& arg)
     {
- return static_cast< ::boost::type_erasure::any<Concept, T&&>&>(arg).data;
+ return std::move(static_cast< ::boost::type_erasure::any<Concept, T&&>&>(arg).data);
+ }
+ template<class Concept, class T>
+ static ::boost::type_erasure::detail::storage&&
+ data(const ::boost::type_erasure::any_base< ::boost::type_erasure::any<Concept, T&&> >& arg)
+ {
+ return std::move(const_cast< ::boost::type_erasure::detail::storage&>(static_cast< const ::boost::type_erasure::any<Concept, T&&>&>(arg).data));
     }
 
     template<class Concept, class T>
@@ -115,6 +121,12 @@
     {
         return std::move(arg._impl.data);
     }
+ template<class Concept, class T>
+ static ::boost::type_erasure::detail::storage&&
+ data(const ::boost::type_erasure::param<Concept, T&&>& arg)
+ {
+ return std::move(const_cast< ::boost::type_erasure::detail::storage&>(arg._impl.data));
+ }
 
 #endif
 

Modified: sandbox/type_erasure/boost/type_erasure/detail/check_call.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/detail/check_call.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/detail/check_call.hpp 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
@@ -52,9 +52,9 @@
         unref
>::type add_const;
     typedef typename ::boost::mpl::if_< ::boost::is_reference<placeholder>,
- unref,
- add_const
- >::type& type;
+ placeholder,
+ add_const&
+ >::type type;
 };
 
 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

Modified: sandbox/type_erasure/boost/type_erasure/detail/construct.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/detail/construct.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/detail/construct.hpp 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
@@ -23,6 +23,96 @@
 
 #define N BOOST_PP_ITERATION()
 
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+#define BOOST_TYPE_ERASURE_FORWARD_I(z, n, data) ::std::forward<BOOST_PP_CAT(U, n)>(BOOST_PP_CAT(u, n))
+#define BOOST_TYPE_ERASURE_FORWARD(n) BOOST_PP_ENUM(n, BOOST_TYPE_ERASURE_FORWARD_I, ~)
+
+#if N > 1
+
+ template<
+ class R
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, class A)
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, class U)
+ >
+ const table_type& _boost_type_erasure_extract_table(
+ ::boost::type_erasure::constructible<R(BOOST_PP_ENUM_PARAMS(N, A))>*
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, U, &u))
+ {
+ return *::boost::type_erasure::detail::BOOST_PP_CAT(extract_table, N)(
+ (R(*)(BOOST_PP_ENUM_PARAMS(N, A)))0,
+ BOOST_PP_ENUM_PARAMS(N, u));
+ }
+
+ template<BOOST_PP_ENUM_PARAMS(N, class U)>
+ any(BOOST_PP_ENUM_BINARY_PARAMS(N, U, &&u))
+ : table(
+ _boost_type_erasure_extract_table(
+ false? this->_boost_type_erasure_deduce_constructor(BOOST_TYPE_ERASURE_FORWARD(N)) : 0
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, u)
+ )
+ ),
+ data(::boost::type_erasure::call(
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(BOOST_TYPE_ERASURE_FORWARD(N)) : 0
+ ), BOOST_TYPE_ERASURE_FORWARD(N))
+ )
+ {}
+
+#endif
+
+ template<BOOST_PP_ENUM_PARAMS(N, class U)>
+ any(const binding<Concept>& binding_arg BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, U, &&u))
+ : table(binding_arg),
+ data(
+ ::boost::type_erasure::call(
+ binding_arg,
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(BOOST_TYPE_ERASURE_FORWARD(N)) : 0
+ )
+ BOOST_PP_COMMA_IF(N)
+ BOOST_TYPE_ERASURE_FORWARD(N)
+ )
+ )
+ {}
+
+ // disambiguate
+ template<BOOST_PP_ENUM_PARAMS(N, class U)>
+ any(binding<Concept>& binding_arg BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, U, &&u))
+ : table(binding_arg),
+ data(
+ ::boost::type_erasure::call(
+ binding_arg,
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(BOOST_TYPE_ERASURE_FORWARD(N)) : 0
+ )
+ BOOST_PP_COMMA_IF(N)
+ BOOST_TYPE_ERASURE_FORWARD(N)
+ )
+ )
+ {}
+
+ // disambiguate
+ template<BOOST_PP_ENUM_PARAMS(N, class U)>
+ any(binding<Concept>&& binding_arg BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, U, &&u))
+ : table(binding_arg),
+ data(
+ ::boost::type_erasure::call(
+ binding_arg,
+ ::boost::type_erasure::detail::make(
+ false? this->_boost_type_erasure_deduce_constructor(BOOST_TYPE_ERASURE_FORWARD(N)) : 0
+ )
+ BOOST_PP_COMMA_IF(N)
+ BOOST_TYPE_ERASURE_FORWARD(N)
+ )
+ )
+ {}
+
+#undef BOOST_TYPE_ERASURE_FORWARD
+#undef BOOST_TYPE_ERASURE_FORWARD_I
+
+#else
+
 #if N > 1
 
     template<
@@ -114,6 +204,8 @@
         )
     {}
 
+#endif
+
 #undef N
 
 #endif

Modified: sandbox/type_erasure/libs/type_erasure/test/test_construct.cpp
==============================================================================
--- sandbox/type_erasure/libs/type_erasure/test/test_construct.cpp (original)
+++ sandbox/type_erasure/libs/type_erasure/test/test_construct.cpp 2013-03-05 16:27:18 EST (Tue, 05 Mar 2013)
@@ -65,72 +65,513 @@
     BOOST_CHECK_EQUAL(any_cast<const char *>(z3), &carray[0]);
 }
 
-BOOST_AUTO_TEST_CASE(test_unary)
-{
- typedef ::boost::mpl::vector<
- common<_a>,
- constructible<_b(_a)>,
- destructible<_b>,
- typeid_<_b>
- > test_concept;
- int i = 1;
- double d = 10;
- tuple<test_concept, _a, _b&> t(i, d);
- any<test_concept, _b> x(get<0>(t));
- BOOST_CHECK_EQUAL(any_cast<double>(x), 1);
+enum {
+ lvalue,
+ const_lvalue,
+ rvalue
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+ = lvalue
+#endif
+};
+
+template<class T>
+int make_arg_type();
+
+template<>
+int make_arg_type<int>() { return rvalue; }
+template<>
+int make_arg_type<int&>() { return lvalue; }
+template<>
+int make_arg_type<const int&>() { return const_lvalue; }
+
+enum { id_int = 4, id_copy = 8 };
+
+std::vector<int> make_vector() { return std::vector<int>(); }
+
+template<class T>
+std::vector<T> make_vector(T t0) {
+ std::vector<T> result;
+ result.push_back(t0);
+ return result;
 }
+template<class T>
+std::vector<T> make_vector(T t0, T t1) {
+ std::vector<T> result;
+ result.push_back(t0);
+ result.push_back(t1);
+ return result;
+}
+
+struct test_class
+{
+
+ test_class() {}
+
+ test_class(const test_class &)
+ : args(make_vector(const_lvalue | id_copy))
+ {}
+
+ test_class(test_class &)
+ : args(make_vector(const_lvalue | id_copy))
+ {}
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+ test_class(test_class &&)
+ : args(make_vector(rvalue | id_copy))
+ {}
+
+ template<class T0>
+ test_class(T0&& t0)
+ : args(make_vector(t0 | make_arg_type<T0>()))
+ {}
+
+ template<class T0, class T1>
+ test_class(T0&& t0, T1&& t1)
+ : args(make_vector(t0 | make_arg_type<T0>(), t1 | make_arg_type<T1>()))
+ {}
+
+#else
+
+ test_class(int& i0)
+ : args(make_vector(i0 | lvalue))
+ {}
+ test_class(const int& i0)
+ : args(make_vector(i0 | const_lvalue))
+ {}
+ test_class(int& i0, int& i1)
+ : args(make_vector(i0 | lvalue, i1 | lvalue))
+ {}
+ test_class(int& i0, const int& i1)
+ : args(make_vector(i0 | lvalue, i1 | const_lvalue))
+ {}
+ test_class(const int& i0, int& i1)
+ : args(make_vector(i0 | const_lvalue, i1 | lvalue))
+ {}
+ test_class(const int& i0, const int& i1)
+ : args(make_vector(i0 | const_lvalue, i1 | const_lvalue))
+ {}
+
+#endif
+ std::vector<int> args;
+};
 
-BOOST_AUTO_TEST_CASE(test_unary_no_const)
+template<class T>
+struct make_arg_impl;
+
+template<>
+struct make_arg_impl<int>
 {
- typedef ::boost::mpl::vector<
- constructible<_b(_a&)>,
- destructible<_b>,
- typeid_<_b>
- > test_concept;
- typedef boost::mpl::map<
- boost::mpl::pair<_a, int>,
- boost::mpl::pair<_b, boost::tuple<int&> >
- > types;
- int i = 1;
- any<test_concept, _a&> x(i, make_binding<types>());
- any<test_concept, _b> y(x);
- BOOST_CHECK_EQUAL(&any_cast<boost::tuple<int&> >(y).get<0>(), &i);
- any<test_concept, _b> z(binding_of(x), x);
- BOOST_CHECK_EQUAL(&any_cast<boost::tuple<int&> >(z).get<0>(), &i);
+ static int apply()
+ {
+ return id_int;
+ }
+};
+
+template<class Concept>
+struct make_arg_impl<binding<Concept> >
+{
+ static binding<Concept> apply()
+ {
+ return make_binding< ::boost::mpl::map<
+ ::boost::mpl::pair<_a, test_class>,
+ ::boost::mpl::pair<_b, int>
+ > >();
+ }
+};
+
+template<class Concept>
+struct make_arg_impl<any<Concept, _a> >
+{
+ static any<Concept, _a> apply()
+ {
+ return any<Concept, _a>(
+ test_class(),
+ make_binding< ::boost::mpl::map<
+ ::boost::mpl::pair<_a, test_class>,
+ ::boost::mpl::pair<_b, int>
+ > >());
+ }
+};
+
+template<class Concept>
+struct make_arg_impl<any<Concept, _b> >
+{
+ static any<Concept, _b> apply()
+ {
+ return any<Concept, _b>(
+ (int)id_int,
+ make_binding< ::boost::mpl::map<
+ ::boost::mpl::pair<_a, test_class>,
+ ::boost::mpl::pair<_b, int>
+ > >());
+ }
+};
+
+template<class Concept, class T>
+struct make_arg_impl<any<Concept, T&> >
+{
+ static any<Concept, T&> apply()
+ {
+ return make_arg_impl<any<Concept, T>&>::apply();
+ }
+};
+
+template<class Concept, class T>
+struct make_arg_impl<any<Concept, const T&> >
+{
+ static any<Concept, const T&> apply()
+ {
+ return make_arg_impl<any<Concept, T>&>::apply();
+ }
+};
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+template<class Concept, class T>
+struct make_arg_impl<any<Concept, T&&> >
+{
+ static any<Concept, T&&> apply()
+ {
+ return std::move(make_arg_impl<any<Concept, T>&>::apply());
+ }
+};
+
+#endif
+
+template<class T>
+struct make_arg_impl<const T> : make_arg_impl<T> {};
+
+template<class T>
+struct make_arg_impl<T&>
+{
+ static T& apply()
+ {
+ static T result = make_arg_impl<T>::apply();
+ return result;
+ }
+};
+
+template<class T>
+T make_arg()
+{
+ return make_arg_impl<T>::apply();
 }
 
-BOOST_AUTO_TEST_CASE(test_from_int)
+int get_value(int i) { return i; }
+template<class T>
+int get_value(const T& t) { return any_cast<int>(t); }
+
+template<class Sig, class Args>
+struct tester;
+
+template<class Concept, class T>
+struct tester<Concept, void(T)>
 {
- typedef ::boost::mpl::vector<
- common<_a>,
- constructible<_a(std::size_t)>
- > test_concept;
- binding<test_concept> types =
- make_binding<
- ::boost::mpl::map<
- ::boost::mpl::pair<_a, std::vector<int> >
- >
- >();
- any<test_concept, _a> x(types, 10);
- std::vector<int> vec(any_cast<std::vector<int> >(x));
- BOOST_CHECK_EQUAL(vec.size(), 10u);
+ static std::vector<int> apply()
+ {
+ any<Concept, _a> x(make_arg<T>());
+ const test_class& result = any_cast<const test_class&>(x);
+ return result.args;
+ }
+};
+
+template<class Concept, class T0, class T1>
+struct tester<Concept, void(T0, T1)>
+{
+ static std::vector<int> apply()
+ {
+ any<Concept, _a> x(make_arg<T0>(), make_arg<T1>());
+ const test_class& result = any_cast<const test_class&>(x);
+ return result.args;
+ }
+};
+
+template<class Concept, class T0, class T1, class T2>
+struct tester<Concept, void(T0, T1, T2)>
+{
+ static std::vector<int> apply()
+ {
+ any<Concept, _a> x(make_arg<T0>(), make_arg<T1>(), make_arg<T2>());
+ const test_class& result = any_cast<const test_class&>(x);
+ return result.args;
+ }
+};
+
+#define TEST_CONSTRUCT(sig, args, expected_) \
+{\
+ typedef ::boost::mpl::vector<\
+ common<_a>, \
+ common<_b>,\
+ constructible<sig>\
+ > C;\
+ std::vector<int> result = tester<C, void args>::apply();\
+ std::vector<int> expected = make_vector expected_;\
+ BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), \
+ expected.begin(), expected.end());\
 }
 
 BOOST_AUTO_TEST_CASE(test_default)
 {
- typedef ::boost::mpl::vector<
- common<_a>,
- constructible<_a()>
- > test_concept;
- binding<test_concept> types =
- make_binding<
- ::boost::mpl::map<
- ::boost::mpl::pair<_a, std::vector<int> >
- >
- >();
- any<test_concept, _a> x(types);
- std::vector<int> vec(any_cast<std::vector<int> >(x));
- BOOST_CHECK_EQUAL(vec.size(), 0u);
+ TEST_CONSTRUCT(_a(), (binding<C>), ());
+ TEST_CONSTRUCT(_a(), (binding<C>&), ());
+ TEST_CONSTRUCT(_a(), (const binding<C>&), ());
+}
+
+// test all forms of direct construction that take 1 argument
+BOOST_AUTO_TEST_CASE(test_construct1)
+{
+ // construction from int
+ TEST_CONSTRUCT(_a(int&), (binding<C>, int&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(int&), (binding<C>&, int&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(int&), (const binding<C>&, int&), (lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(const int&), (binding<C>, int), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (binding<C>, int&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (binding<C>, const int&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (binding<C>&, int), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (binding<C>&, int&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (binding<C>&, const int&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (const binding<C>&, int), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (const binding<C>&, int&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const int&), (const binding<C>&, const int&), (const_lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(int), (binding<C>, int), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (binding<C>, int&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (binding<C>, const int&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (binding<C>&, int), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (binding<C>&, int&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (binding<C>&, const int&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (const binding<C>&, int), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (const binding<C>&, int&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int), (const binding<C>&, const int&), (rvalue | id_int));
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ TEST_CONSTRUCT(_a(int&&), (binding<C>, int), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int&&), (binding<C>&, int), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(int&&), (const binding<C>&, int), (rvalue | id_int));
+#endif
+
+ // Test same any type
+
+#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+ // ambiguous with the copy constructor in C++03
+ TEST_CONSTRUCT(_a(_a&), (any<C, _a>&), (lvalue | id_copy));
+ TEST_CONSTRUCT(_a(_a&), (binding<C>, any<C, _a>&), (lvalue | id_copy));
+ TEST_CONSTRUCT(_a(_a&), (binding<C>&, any<C, _a>&), (lvalue | id_copy));
+ TEST_CONSTRUCT(_a(_a&), (const binding<C>&, any<C, _a>&), (lvalue | id_copy));
+#endif
+
+ TEST_CONSTRUCT(_a(const _a&), (any<C, _a>), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (any<C, _a>&), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (const any<C, _a>&), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (binding<C>, any<C, _a>), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (binding<C>, any<C, _a>&), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (binding<C>, const any<C, _a>&), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (binding<C>&, any<C, _a>), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (binding<C>&, any<C, _a>&), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (binding<C>&, const any<C, _a>&), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (const binding<C>&, any<C, _a>), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (const binding<C>&, any<C, _a>&), (const_lvalue | id_copy));
+ TEST_CONSTRUCT(_a(const _a&), (const binding<C>&, const any<C, _a>&), (const_lvalue | id_copy));
+
+#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ TEST_CONSTRUCT(_a(_a&&), (any<C, _a>), (rvalue | id_copy));
+ TEST_CONSTRUCT(_a(_a&&), (binding<C>, any<C, _a>), (rvalue | id_copy));
+ TEST_CONSTRUCT(_a(_a&&), (binding<C>&, any<C, _a>), (rvalue | id_copy));
+ TEST_CONSTRUCT(_a(_a&&), (const binding<C>&, any<C, _a>), (rvalue | id_copy));
+#endif
+
+#endif
+
+ // test other any type
+ TEST_CONSTRUCT(_a(_b&), (any<C, _b>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>, any<C, _b>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>&, any<C, _b>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (const binding<C>&, any<C, _b>&), (lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(const _b&), (any<C, _b>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (any<C, _b>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const any<C, _b>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, _b>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, _b>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, const any<C, _b>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, _b>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, _b>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, const any<C, _b>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, _b>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, _b>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, const any<C, _b>&), (const_lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(_b), (any<C, _b>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (any<C, _b>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const any<C, _b>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, _b>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, _b>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, const any<C, _b>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, _b>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, _b>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, const any<C, _b>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, const any<C, _b>&), (rvalue | id_int));
+
+#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ TEST_CONSTRUCT(_a(_b&&), (any<C, _b>), (rvalue | id_copy));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>, any<C, _b>), (rvalue | id_copy));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>&, any<C, _b>), (rvalue | id_copy));
+ TEST_CONSTRUCT(_a(_b&&), (const binding<C>&, any<C, _b>), (rvalue | id_copy));
+#endif
+
+#endif
+
+ // test any reference type
+ TEST_CONSTRUCT(_a(_b&), (any<C, _b&>), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (any<C, _b&>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (const any<C, _b&>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>, any<C, _b&>), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>, any<C, _b&>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>, const any<C, _b&>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>&, any<C, _b&>), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>&, any<C, _b&>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (binding<C>&, const any<C, _b&>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (const binding<C>&, any<C, _b&>), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (const binding<C>&, any<C, _b&>&), (lvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&), (const binding<C>&, const any<C, _b&>&), (lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(const _b&), (any<C, _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (any<C, _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const any<C, _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, const any<C, _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, const any<C, _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, const any<C, _b&>&), (const_lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(_b), (any<C, _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (any<C, _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const any<C, _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, const any<C, _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, const any<C, _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, const any<C, _b&>&), (rvalue | id_int));
+
+ // test const any reference type
+ TEST_CONSTRUCT(_a(const _b&), (any<C, const _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (any<C, const _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const any<C, const _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, const _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, const _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, const any<C, const _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, const _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, const _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, const any<C, const _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, const _b&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, const _b&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, const any<C, const _b&>&), (const_lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(_b), (any<C, const _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (any<C, const _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const any<C, const _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, const _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, const _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, const any<C, const _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, const _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, const _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, const any<C, const _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, const _b&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, const _b&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, const any<C, const _b&>&), (rvalue | id_int));
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+ // test any rvalue reference type
+ TEST_CONSTRUCT(_a(const _b&), (any<C, _b&&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (any<C, _b&&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const any<C, _b&&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, _b&&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, any<C, _b&&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>, const any<C, _b&&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, _b&&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, any<C, _b&&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (binding<C>&, const any<C, _b&&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, _b&&>), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, any<C, _b&&>&), (const_lvalue | id_int));
+ TEST_CONSTRUCT(_a(const _b&), (const binding<C>&, const any<C, _b&&>&), (const_lvalue | id_int));
+
+ TEST_CONSTRUCT(_a(_b), (any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>, const any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (binding<C>&, const any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b), (const binding<C>&, const any<C, _b&&>&), (rvalue | id_int));
+
+ TEST_CONSTRUCT(_a(_b&&), (any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (const any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>, any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>, any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>, const any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>&, any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>&, any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (binding<C>&, const any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (const binding<C>&, any<C, _b&&>), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (const binding<C>&, any<C, _b&&>&), (rvalue | id_int));
+ TEST_CONSTRUCT(_a(_b&&), (const binding<C>&, const any<C, _b&&>&), (rvalue | id_int));
+
+#endif
+
+}
+
+// test constructors with 2 parameters
+BOOST_AUTO_TEST_CASE(test_construct2)
+{
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, int, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, int, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, int, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, int&, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, int&, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, int&, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, const int&, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, const int&, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>, const int&, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, int, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, int, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, int, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, int&, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, int&, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, int&, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, const int&, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, const int&, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (binding<C>&, const int&, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, int, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, int, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, int, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, int&, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, int&, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, int&, const int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, const int&, int), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, const int&, int&), (rvalue | id_int, rvalue | id_int));
+ TEST_CONSTRUCT(_a(int, int), (const binding<C>&, const int&, const int&), (rvalue | id_int, rvalue | id_int));
 }
 
 BOOST_AUTO_TEST_CASE(test_overload)
@@ -155,7 +596,6 @@
     BOOST_CHECK_EQUAL(vec2.size(), 17u);
 }
 
-
 template<class T>
 T as_rvalue(const T& arg) { return arg; }
 template<class T>
@@ -164,8 +604,30 @@
 BOOST_AUTO_TEST_CASE(test_from_int_with_binding)
 {
     typedef ::boost::mpl::vector<common<> > test_concept;
- any<test_concept> x(4, make_binding<boost::mpl::map<boost::mpl::pair<_self, int> > >());
- BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
+ static_binding<boost::mpl::map<boost::mpl::pair<_self, int> > > binding =
+ make_binding<boost::mpl::map<boost::mpl::pair<_self, int> > >();
+ int value = 4;
+
+ any<test_concept> x1(value, binding);
+ BOOST_CHECK_EQUAL(any_cast<int>(x1), 4);
+ any<test_concept> x2(value, as_rvalue(binding));
+ BOOST_CHECK_EQUAL(any_cast<int>(x2), 4);
+ any<test_concept> x3(value, as_const(binding));
+ BOOST_CHECK_EQUAL(any_cast<int>(x3), 4);
+
+ any<test_concept> y1(as_rvalue(value), binding);
+ BOOST_CHECK_EQUAL(any_cast<int>(y1), 4);
+ any<test_concept> y2(as_rvalue(value), as_rvalue(binding));
+ BOOST_CHECK_EQUAL(any_cast<int>(y2), 4);
+ any<test_concept> y3(as_rvalue(value), as_const(binding));
+ BOOST_CHECK_EQUAL(any_cast<int>(y3), 4);
+
+ any<test_concept> z1(as_const(value), binding);
+ BOOST_CHECK_EQUAL(any_cast<int>(z1), 4);
+ any<test_concept> z2(as_const(value), as_rvalue(binding));
+ BOOST_CHECK_EQUAL(any_cast<int>(z2), 4);
+ any<test_concept> z3(as_const(value), as_const(binding));
+ BOOST_CHECK_EQUAL(any_cast<int>(z3), 4);
 }
 
 BOOST_AUTO_TEST_CASE(test_copy)
@@ -201,7 +663,7 @@
     typedef ::boost::mpl::vector<common<_a> > dst_concept;
     any<src_concept> x(4);
     BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
- any<dst_concept, _a> y(x);
+ any<dst_concept, _a> y = x;
     BOOST_CHECK_EQUAL(any_cast<int>(y), 4);
     any<dst_concept, _a> z = as_rvalue(x);
     BOOST_CHECK_EQUAL(any_cast<int>(z), 4);
@@ -230,19 +692,53 @@
     typedef ::boost::mpl::map<boost::mpl::pair<_a, _self> > map;
     typedef ::boost::mpl::map<boost::mpl::pair<_a, int> > types;
 
+ static_binding<map> s_table(make_binding<map>());
     binding<dst_concept> table(make_binding<types>());
     
     any<src_concept> x(4);
     BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
- any<dst_concept, _a> y(x, make_binding<map>());
- BOOST_CHECK_EQUAL(any_cast<int>(y), 4);
- any<dst_concept, _a> z(x, table);
- BOOST_CHECK_EQUAL(any_cast<int>(z), 4);
+
+ // lvalues
+ any<dst_concept, _a> y1(x, s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(y1), 4);
+ any<dst_concept, _a> y2(x, as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y2), 4);
+ any<dst_concept, _a> y3(x, as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y3), 4);
+ any<dst_concept, _a> z1(x, table);
+ BOOST_CHECK_EQUAL(any_cast<int>(z1), 4);
+ any<dst_concept, _a> z2(x, as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z2), 4);
+ any<dst_concept, _a> z3(x, as_const(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z3), 4);
     
- any<dst_concept, _a> cy(as_const(x), make_binding<map>());
- BOOST_CHECK_EQUAL(any_cast<int>(cy), 4);
- any<dst_concept, _a> cz(as_const(x), table);
- BOOST_CHECK_EQUAL(any_cast<int>(cz), 4);
+ // rvalues
+ any<dst_concept, _a> ry1(as_rvalue(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(ry1), 4);
+ any<dst_concept, _a> ry2(as_rvalue(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry2), 4);
+ any<dst_concept, _a> ry3(as_rvalue(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry3), 4);
+ any<dst_concept, _a> rz1(as_rvalue(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(rz1), 4);
+ any<dst_concept, _a> rz2(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz2), 4);
+ any<dst_concept, _a> rz3(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz3), 4);
+
+ // const lvalues
+ any<dst_concept, _a> cy1(as_const(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cy1), 4);
+ any<dst_concept, _a> cy2(as_const(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy2), 4);
+ any<dst_concept, _a> cy3(as_const(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy3), 4);
+ any<dst_concept, _a> cz1(as_const(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cz1), 4);
+ any<dst_concept, _a> cz2(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz2), 4);
+ any<dst_concept, _a> cz3(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz3), 4);
 }
 
 BOOST_AUTO_TEST_CASE(test_copy_from_ref)
@@ -310,21 +806,55 @@
     typedef ::boost::mpl::vector<common<_a> > dst_concept;
     typedef ::boost::mpl::map<boost::mpl::pair<_a, _self> > map;
     typedef ::boost::mpl::map<boost::mpl::pair<_a, int> > types;
-
+
+ static_binding<map> s_table(make_binding<map>());
     binding<dst_concept> table(make_binding<types>());
     
     int i = 4;
     any<src_concept, _self&> x(i);
     BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
- any<dst_concept, _a> y(x, make_binding<map>());
- BOOST_CHECK_EQUAL(any_cast<int>(y), 4);
- any<dst_concept, _a> z(x, table);
- BOOST_CHECK_EQUAL(any_cast<int>(z), 4);
+
+ // lvalues
+ any<dst_concept, _a> y1(x, s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(y1), 4);
+ any<dst_concept, _a> y2(x, as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y2), 4);
+ any<dst_concept, _a> y3(x, as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y3), 4);
+ any<dst_concept, _a> z1(x, table);
+ BOOST_CHECK_EQUAL(any_cast<int>(z1), 4);
+ any<dst_concept, _a> z2(x, as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z2), 4);
+ any<dst_concept, _a> z3(x, as_const(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z3), 4);
     
- any<dst_concept, _a> cy(as_const(x), make_binding<map>());
- BOOST_CHECK_EQUAL(any_cast<int>(cy), 4);
- any<dst_concept, _a> cz(as_const(x), table);
- BOOST_CHECK_EQUAL(any_cast<int>(cz), 4);
+ // rvalues
+ any<dst_concept, _a> ry1(as_rvalue(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(ry1), 4);
+ any<dst_concept, _a> ry2(as_rvalue(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry2), 4);
+ any<dst_concept, _a> ry3(as_rvalue(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry3), 4);
+ any<dst_concept, _a> rz1(as_rvalue(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(rz1), 4);
+ any<dst_concept, _a> rz2(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz2), 4);
+ any<dst_concept, _a> rz3(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz3), 4);
+
+ // const lvalues
+ any<dst_concept, _a> cy1(as_const(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cy1), 4);
+ any<dst_concept, _a> cy2(as_const(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy2), 4);
+ any<dst_concept, _a> cy3(as_const(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy3), 4);
+ any<dst_concept, _a> cz1(as_const(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cz1), 4);
+ any<dst_concept, _a> cz2(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz2), 4);
+ any<dst_concept, _a> cz3(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz3), 4);
 }
 
 BOOST_AUTO_TEST_CASE(test_copy_from_cref)
@@ -392,19 +922,173 @@
     typedef ::boost::mpl::vector<common<_a> > dst_concept;
     typedef ::boost::mpl::map<boost::mpl::pair<_a, _self> > map;
     typedef ::boost::mpl::map<boost::mpl::pair<_a, int> > types;
-
+
+ static_binding<map> s_table(make_binding<map>());
     binding<dst_concept> table(make_binding<types>());
     
     int i = 4;
     any<src_concept, const _self&> x(i);
     BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
- any<dst_concept, _a> y(x, make_binding<map>());
+
+ // lvalues
+ any<dst_concept, _a> y1(x, s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(y1), 4);
+ any<dst_concept, _a> y2(x, as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y2), 4);
+ any<dst_concept, _a> y3(x, as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y3), 4);
+ any<dst_concept, _a> z1(x, table);
+ BOOST_CHECK_EQUAL(any_cast<int>(z1), 4);
+ any<dst_concept, _a> z2(x, as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z2), 4);
+ any<dst_concept, _a> z3(x, as_const(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z3), 4);
+
+ // rvalues
+ any<dst_concept, _a> ry1(as_rvalue(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(ry1), 4);
+ any<dst_concept, _a> ry2(as_rvalue(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry2), 4);
+ any<dst_concept, _a> ry3(as_rvalue(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry3), 4);
+ any<dst_concept, _a> rz1(as_rvalue(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(rz1), 4);
+ any<dst_concept, _a> rz2(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz2), 4);
+ any<dst_concept, _a> rz3(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz3), 4);
+
+ // const lvalues
+ any<dst_concept, _a> cy1(as_const(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cy1), 4);
+ any<dst_concept, _a> cy2(as_const(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy2), 4);
+ any<dst_concept, _a> cy3(as_const(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy3), 4);
+ any<dst_concept, _a> cz1(as_const(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cz1), 4);
+ any<dst_concept, _a> cz2(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz2), 4);
+ any<dst_concept, _a> cz3(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz3), 4);
+}
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+BOOST_AUTO_TEST_CASE(test_copy_from_rref)
+{
+ typedef ::boost::mpl::vector<common<> > test_concept;
+ int i = 4;
+ any<test_concept, _self&&> x(std::move(i));
+ BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
+ any<test_concept> y(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(y), 4);
+ any<test_concept> z = as_rvalue(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(z), 4);
+ any<test_concept> w = as_const(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(w), 4);
+}
+
+BOOST_AUTO_TEST_CASE(test_convert_from_rref)
+{
+ typedef ::boost::mpl::vector<common<>, incrementable<> > src_concept;
+ typedef ::boost::mpl::vector<common<> > dst_concept;
+ int i = 4;
+ any<src_concept, _self&&> x(std::move(i));
+ BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
+ any<dst_concept> y(x);
     BOOST_CHECK_EQUAL(any_cast<int>(y), 4);
- any<dst_concept, _a> z(x, table);
+ any<dst_concept> z = as_rvalue(x);
     BOOST_CHECK_EQUAL(any_cast<int>(z), 4);
+ any<dst_concept> w = as_const(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(w), 4);
+}
+
+BOOST_AUTO_TEST_CASE(test_rebind_from_rref)
+{
+ typedef ::boost::mpl::vector<common<> > src_concept;
+ typedef ::boost::mpl::vector<common<_a> > dst_concept;
+ int i = 4;
+ any<src_concept, _self&&> x(std::move(i));
+ BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
+ any<dst_concept, _a> y(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(y), 4);
+ any<dst_concept, _a> z = as_rvalue(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(z), 4);
+ any<dst_concept, _a> w = as_const(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(w), 4);
+}
+
+BOOST_AUTO_TEST_CASE(test_rebind_and_convert_from_rref)
+{
+ typedef ::boost::mpl::vector<common<>, incrementable<> > src_concept;
+ typedef ::boost::mpl::vector<common<_a> > dst_concept;
+ int i = 4;
+ any<src_concept, _self&&> x(std::move(i));
+ BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
+ any<dst_concept, _a> y(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(y), 4);
+ any<dst_concept, _a> z = as_rvalue(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(z), 4);
+ any<dst_concept, _a> w = as_const(x);
+ BOOST_CHECK_EQUAL(any_cast<int>(w), 4);
+}
+
+BOOST_AUTO_TEST_CASE(test_rebind_and_convert_with_binding_from_rref)
+{
+ typedef ::boost::mpl::vector<common<>, incrementable<> > src_concept;
+ typedef ::boost::mpl::vector<common<_a> > dst_concept;
+ typedef ::boost::mpl::map<boost::mpl::pair<_a, _self> > map;
+ typedef ::boost::mpl::map<boost::mpl::pair<_a, int> > types;
     
- any<dst_concept, _a> cy(as_const(x), make_binding<map>());
- BOOST_CHECK_EQUAL(any_cast<int>(cy), 4);
- any<dst_concept, _a> cz(as_const(x), table);
- BOOST_CHECK_EQUAL(any_cast<int>(cz), 4);
+ static_binding<map> s_table(make_binding<map>());
+ binding<dst_concept> table(make_binding<types>());
+
+ int i = 4;
+ any<src_concept, _self&&> x(std::move(i));
+ BOOST_CHECK_EQUAL(any_cast<int>(x), 4);
+
+ // lvalues
+ any<dst_concept, _a> y1(x, s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(y1), 4);
+ any<dst_concept, _a> y2(x, as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y2), 4);
+ any<dst_concept, _a> y3(x, as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(y3), 4);
+ any<dst_concept, _a> z1(x, table);
+ BOOST_CHECK_EQUAL(any_cast<int>(z1), 4);
+ any<dst_concept, _a> z2(x, as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z2), 4);
+ any<dst_concept, _a> z3(x, as_const(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(z3), 4);
+
+ // rvalues
+ any<dst_concept, _a> ry1(as_rvalue(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(ry1), 4);
+ any<dst_concept, _a> ry2(as_rvalue(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry2), 4);
+ any<dst_concept, _a> ry3(as_rvalue(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(ry3), 4);
+ any<dst_concept, _a> rz1(as_rvalue(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(rz1), 4);
+ any<dst_concept, _a> rz2(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz2), 4);
+ any<dst_concept, _a> rz3(as_rvalue(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(rz3), 4);
+
+ // const lvalues
+ any<dst_concept, _a> cy1(as_const(x), s_table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cy1), 4);
+ any<dst_concept, _a> cy2(as_const(x), as_rvalue(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy2), 4);
+ any<dst_concept, _a> cy3(as_const(x), as_const(s_table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cy3), 4);
+ any<dst_concept, _a> cz1(as_const(x), table);
+ BOOST_CHECK_EQUAL(any_cast<int>(cz1), 4);
+ any<dst_concept, _a> cz2(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz2), 4);
+ any<dst_concept, _a> cz3(as_const(x), as_rvalue(table));
+ BOOST_CHECK_EQUAL(any_cast<int>(cz3), 4);
 }
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk