Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86213 - in trunk: boost libs/any/test
From: antoshkka_at_[hidden]
Date: 2013-10-09 10:34:16


Author: apolukhin
Date: 2013-10-09 10:34:15 EDT (Wed, 09 Oct 2013)
New Revision: 86213
URL: http://svn.boost.org/trac/boost/changeset/86213

Log:
Fix for construction of `any` from `const any&&` (refs #9215)

Text files modified:
   trunk/boost/any.hpp | 5 ++++-
   trunk/libs/any/test/any_test_rv.cpp | 16 ++++++++++++++++
   2 files changed, 20 insertions(+), 1 deletions(-)

Modified: trunk/boost/any.hpp
==============================================================================
--- trunk/boost/any.hpp Wed Oct 9 10:11:50 2013 (r86212)
+++ trunk/boost/any.hpp 2013-10-09 10:34:15 EDT (Wed, 09 Oct 2013) (r86213)
@@ -27,6 +27,7 @@
 #include <boost/static_assert.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_const.hpp>
 
 // See boost/python/type_id.hpp
 // TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp
@@ -76,7 +77,9 @@
 
         // Perfect forwarding of ValueType
         template<typename ValueType>
- any(ValueType&& value, typename boost::disable_if<boost::is_same<any&, ValueType> >::type* = 0)
+ any(ValueType&& value
+ , typename boost::disable_if<boost::is_same<any&, ValueType> >::type* = 0 // disable if value has type `any&`
+ , typename boost::disable_if<boost::is_const<ValueType> >::type* = 0) // disable if value has type `const ValueType&&`
           : content(new holder< typename decay<ValueType>::type >(static_cast<ValueType&&>(value)))
         {
         }

Modified: trunk/libs/any/test/any_test_rv.cpp
==============================================================================
--- trunk/libs/any/test/any_test_rv.cpp Wed Oct 9 10:11:50 2013 (r86212)
+++ trunk/libs/any/test/any_test_rv.cpp 2013-10-09 10:34:15 EDT (Wed, 09 Oct 2013) (r86213)
@@ -51,6 +51,7 @@
     void test_move_assignment_from_value();
     void test_copy_construction_from_value();
     void test_copy_assignment_from_value();
+ void test_construction_from_const_any_rv();
     void test_cast_to_rv();
     
 
@@ -65,6 +66,7 @@
         { "move assignment from value", test_move_assignment_from_value },
         { "copy construction from value", test_copy_construction_from_value },
         { "copy assignment from value", test_copy_assignment_from_value },
+ { "constructing from const any&&", test_construction_from_const_any_rv },
         { "casting to rvalue reference", test_cast_to_rv }
     };
 
@@ -275,6 +277,20 @@
             "checking move counts");
     }
 
+ const any helper_method() {
+ return true;
+ }
+
+ const bool helper_method1() {
+ return true;
+ }
+
+ void test_construction_from_const_any_rv()
+ {
+ any values[] = {helper_method(), helper_method1() };
+ (void)values;
+ }
+
     void test_cast_to_rv()
     {
         move_copy_conting_class value0;


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