$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r80962 - in sandbox/type_erasure: boost/type_erasure libs/type_erasure/doc libs/type_erasure/test
From: steven_at_[hidden]
Date: 2012-10-11 17:33:50
Author: steven_watanabe
Date: 2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
New Revision: 80962
URL: http://svn.boost.org/trac/boost/changeset/80962
Log:
Enable implicit conversion to any.
Text files modified: 
   sandbox/type_erasure/boost/type_erasure/any.hpp                     |     8 ++++----                                
   sandbox/type_erasure/boost/type_erasure/callable.hpp                |    11 ++++++-----                             
   sandbox/type_erasure/boost/type_erasure/constructible.hpp           |    12 ++++++------                            
   sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk         |    21 ---------------------                   
   sandbox/type_erasure/libs/type_erasure/test/test_construct.cpp      |     5 +++++                                   
   sandbox/type_erasure/libs/type_erasure/test/test_construct_cref.cpp |     6 ++++++                                  
   sandbox/type_erasure/libs/type_erasure/test/test_construct_ref.cpp  |     6 ++++++                                  
   7 files changed, 33 insertions(+), 36 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	2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
@@ -172,7 +172,7 @@
      *         constructor of @c U throws.
      */
     template<class U>
-    explicit any(const U& data_arg)
+    any(const U& data_arg)
       : table((
             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
             ::boost::type_erasure::make_binding<
@@ -846,7 +846,7 @@
      * \throws Nothing.
      */
     template<class U>
-    explicit any(U& arg
+    any(U& arg
 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
         ,  typename ::boost::disable_if<
             ::boost::mpl::or_<
@@ -1250,7 +1250,7 @@
      * \throws Nothing.
      */
     template<class U>
-    explicit any(const U& arg)
+    any(const U& arg)
       : table((
             BOOST_TYPE_ERASURE_INSTANTIATE1(Concept, T, U),
             ::boost::type_erasure::make_binding<
@@ -1464,7 +1464,7 @@
      * \throws Nothing.
      */
     template<class U>
-    explicit any(U&& arg
+    any(U&& arg
 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
         ,  typename ::boost::disable_if<
             ::boost::mpl::or_<
Modified: sandbox/type_erasure/boost/type_erasure/callable.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/callable.hpp	(original)
+++ sandbox/type_erasure/boost/type_erasure/callable.hpp	2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
@@ -28,6 +28,7 @@
 #include <boost/type_erasure/call.hpp>
 #include <boost/type_erasure/concept_interface.hpp>
 #include <boost/type_erasure/rebind_any.hpp>
+#include <boost/type_erasure/param.hpp>
 
 namespace boost {
 namespace type_erasure {
@@ -90,7 +91,7 @@
     _boost_type_erasure_deduce_callable(
         typename ::boost::type_erasure::rebind_any<Base, T>::type...);
     typename ::boost::type_erasure::rebind_any<Base, R>::type
-    operator()(typename ::boost::type_erasure::rebind_any<Base, T>::type... arg)
+    operator()(typename ::boost::type_erasure::as_param<Base, T>::type... arg)
     {
         return ::boost::type_erasure::call(callable<R(T...), F>(), *this, arg...);
     }
@@ -111,7 +112,7 @@
     _boost_type_erasure_deduce_callable(
         typename ::boost::type_erasure::rebind_any<Base, T>::type...) const;
     typename ::boost::type_erasure::rebind_any<Base, R>::type operator()(
-        typename ::boost::type_erasure::rebind_any<Base, T>::type... arg) const
+        typename ::boost::type_erasure::as_param<Base, T>::type... arg) const
     {
         return ::boost::type_erasure::call(callable<R(T...), const F>(), *this, arg...);
     }
@@ -138,7 +139,7 @@
         typename ::boost::type_erasure::rebind_any<Base, T>::type...);
     using Base::operator();
     typename ::boost::type_erasure::rebind_any<Base, R>::type
-    operator()(typename ::boost::type_erasure::rebind_any<Base, T>::type... arg)
+    operator()(typename ::boost::type_erasure::as_param<Base, T>::type... arg)
     {
         return ::boost::type_erasure::call(callable<R(T...), F>(), *this, arg...);
     }
@@ -165,7 +166,7 @@
         typename ::boost::type_erasure::rebind_any<Base, T>::type...) const;
     using Base::operator();
     typename ::boost::type_erasure::rebind_any<Base, R>::type
-    operator()(typename ::boost::type_erasure::rebind_any<Base, T>::type... arg) const
+    operator()(typename ::boost::type_erasure::as_param<Base, T>::type... arg) const
     {
         return ::boost::type_erasure::call(callable<R(T...), const F>(), *this, arg...);
     }
@@ -206,7 +207,7 @@
 #define BOOST_TYPE_ERASURE_DECLVAL(z, n, data) ::boost::declval<BOOST_PP_CAT(T, n)>()
 
 #define BOOST_TYPE_ERASURE_REBIND(z, n, data)\
-    typename ::boost::type_erasure::rebind_any<Base, BOOST_PP_CAT(T, n)>::type BOOST_PP_CAT(arg, n)
+    typename ::boost::type_erasure::as_param<Base, BOOST_PP_CAT(T, n)>::type BOOST_PP_CAT(arg, n)
 
 template<class R BOOST_PP_ENUM_TRAILING_PARAMS(N, class T), class F>
 struct callable<R(BOOST_PP_ENUM_PARAMS(N, T)), F>
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	2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
@@ -21,7 +21,7 @@
 #include <boost/type_erasure/call.hpp>
 #include <boost/type_erasure/concept_interface.hpp>
 #include <boost/type_erasure/config.hpp>
-#include <boost/type_erasure/rebind_any.hpp>
+#include <boost/type_erasure/param.hpp>
 
 namespace boost {
 namespace type_erasure {
@@ -80,7 +80,7 @@
     using Base::_boost_type_erasure_deduce_constructor;
     ::boost::type_erasure::constructible<R(T...)>*
     _boost_type_erasure_deduce_constructor(
-        typename ::boost::type_erasure::rebind_any<Base, T>::type...)
+        typename ::boost::type_erasure::as_param<Base, T>::type...)
     {
         return 0;
     }
@@ -126,7 +126,7 @@
 #define N BOOST_PP_ITERATION()
 
 #define BOOST_TYPE_ERASURE_ARG_DECL(z, n, data)     \
-    typename ::boost::type_erasure::rebind_any<     \
+    typename ::boost::type_erasure::as_param<          \
         Base,                                       \
         BOOST_PP_CAT(T, n)                          \
     >::type
@@ -143,15 +143,15 @@
     }
 };
 
-template<class Base, class R BOOST_PP_ENUM_TRAILING_PARAMS(N, class T), class Tag>
+template<class Base BOOST_PP_ENUM_TRAILING_PARAMS(N, class T), class Tag>
 struct concept_interface<
-    ::boost::type_erasure::constructible<R(BOOST_PP_ENUM_PARAMS(N, T))>,
+    ::boost::type_erasure::constructible<Tag(BOOST_PP_ENUM_PARAMS(N, T))>,
     Base,
     Tag
 > : Base
 {
     using Base::_boost_type_erasure_deduce_constructor;
-    ::boost::type_erasure::constructible<R(BOOST_PP_ENUM_PARAMS(N, T))>*
+    ::boost::type_erasure::constructible<Tag(BOOST_PP_ENUM_PARAMS(N, T))>*
     _boost_type_erasure_deduce_constructor(
         BOOST_PP_ENUM(N, BOOST_TYPE_ERASURE_ARG_DECL, ~))
     {
Modified: sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk
==============================================================================
--- sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk	(original)
+++ sandbox/type_erasure/libs/type_erasure/doc/type_erasure.qbk	2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
@@ -564,27 +564,6 @@
   substitute for template parameters, I'd really like
   to use `_T`.  Alack-a-day, `_T` is a reserved identifier.
   `_self` was the best I could think of.
-* Implicit conversions.  Implicit conversion from the
-  contained type to a reference any is not allowed.
-  The reason for this is that I found that such
-  conversions were interefering with overload resolution.
-  Getting overload resolution to work correctly in
-  the following would be a lot more difficult if
-  implicit conversion were allowed:
-  ``
-    typedef mpl::vector<
-        copy_constructible<>,
-        constructible<_self(const std::string&)>
-    > concept;
-    any<concept> x = ...;
-    any<concept> y(binding_of(x), "hello");
-  ``
-  Without great care we end up with an ambiguity
-  between the `std::string` constructor and the
-  copy constructor.  User-defined overloaded
-  functions would also need to handle this somehow.
-  I decided that it was better to avoid the whole
-  problem by disabling implicit conversions.
 * __relaxed_match.  I considered a lot of names
   for this, `strict_match<false>`, `enable_mixed`,
   `nonstrict_match`, `loose_match`, `best_effort`,
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	2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
@@ -29,6 +29,11 @@
     typeid_<T>
 > {};
 
+BOOST_AUTO_TEST_CASE(test_implicit) {
+    any<common<> > x = 1;
+    BOOST_CHECK_EQUAL(any_cast<int>(x), 1);
+}
+
 BOOST_AUTO_TEST_CASE(test_unary)
 {
     typedef ::boost::mpl::vector<
Modified: sandbox/type_erasure/libs/type_erasure/test/test_construct_cref.cpp
==============================================================================
--- sandbox/type_erasure/libs/type_erasure/test/test_construct_cref.cpp	(original)
+++ sandbox/type_erasure/libs/type_erasure/test/test_construct_cref.cpp	2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
@@ -31,6 +31,12 @@
 template<class T>
 const T& as_const(const T& arg) { return arg; }
 
+BOOST_AUTO_TEST_CASE(test_implicit) {
+    int i = 4;
+    any<common<>, const _self&> x = i;
+    BOOST_CHECK_EQUAL(any_cast<const int*>(&x), &i);
+}
+
 BOOST_AUTO_TEST_CASE(test_from_int_with_binding)
 {
     typedef ::boost::mpl::vector<common<> > test_concept;
Modified: sandbox/type_erasure/libs/type_erasure/test/test_construct_ref.cpp
==============================================================================
--- sandbox/type_erasure/libs/type_erasure/test/test_construct_ref.cpp	(original)
+++ sandbox/type_erasure/libs/type_erasure/test/test_construct_ref.cpp	2012-10-11 17:33:49 EDT (Thu, 11 Oct 2012)
@@ -31,6 +31,12 @@
 template<class T>
 const T& as_const(const T& arg) { return arg; }
 
+BOOST_AUTO_TEST_CASE(test_implicit) {
+    int i = 4;
+    any<common<>, _self&> x = i;
+    BOOST_CHECK_EQUAL(any_cast<int*>(&x), &i);
+}
+
 BOOST_AUTO_TEST_CASE(test_from_int_with_binding)
 {
     typedef ::boost::mpl::vector<common<> > test_concept;