|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85104 - in trunk: boost/type_traits libs/type_traits/test
From: antoshkka_at_[hidden]
Date: 2013-07-22 08:51:09
Author: apolukhin
Date: 2013-07-22 08:51:09 EDT (Mon, 22 Jul 2013)
New Revision: 85104
URL: http://svn.boost.org/trac/boost/changeset/85104
Log:
Unify behavior of is_copy_constructible triat when dealing with rvalues + add comments for some tests (refs #8802):
Text files modified:
trunk/boost/type_traits/is_copy_constructible.hpp | 9 ++++++---
trunk/libs/type_traits/test/is_copy_constructible_test.cpp | 20 ++++++++++++++++++--
2 files changed, 24 insertions(+), 5 deletions(-)
Modified: trunk/boost/type_traits/is_copy_constructible.hpp
==============================================================================
--- trunk/boost/type_traits/is_copy_constructible.hpp Mon Jul 22 07:50:26 2013 (r85103)
+++ trunk/boost/type_traits/is_copy_constructible.hpp 2013-07-22 08:51:09 EDT (Mon, 22 Jul 2013) (r85104)
@@ -13,6 +13,7 @@
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/type_traits/add_reference.hpp>
+#include <boost/type_traits/is_rvalue_reference.hpp>
#include <boost/utility/declval.hpp>
#include <boost/noncopyable.hpp>
@@ -67,9 +68,11 @@
// ...
// };
BOOST_STATIC_CONSTANT(bool, value = (
- sizeof(test(
- boost::declval<BOOST_DEDUCED_TYPENAME boost::add_reference<T>::type>()
- )) == sizeof(boost::type_traits::yes_type)
+ sizeof(test(
+ boost::declval<BOOST_DEDUCED_TYPENAME boost::add_reference<T>::type>()
+ )) == sizeof(boost::type_traits::yes_type)
+ ||
+ boost::is_rvalue_reference<T>::value
));
};
Modified: trunk/libs/type_traits/test/is_copy_constructible_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/is_copy_constructible_test.cpp Mon Jul 22 07:50:26 2013 (r85103)
+++ trunk/libs/type_traits/test/is_copy_constructible_test.cpp 2013-07-22 08:51:09 EDT (Mon, 22 Jul 2013) (r85104)
@@ -259,11 +259,27 @@
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible<int&>::value, true);
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
-BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible<int&&>::value, false);
+// Code like `int&& a = 10;` or
+// struct nonc {
+// nonc() = default;
+// nonc(const nonc&) = delete;
+// nonc(nonc&&) = delete;
+// nonc& operator=(const nonc&) = delete;
+// nonc& operator=(nonc&&) = delete;
+// };
+//
+// nonc && a = nonc();
+// is legal in C++11. so this trait MUST return true.
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible<int&&>::value, true);
#endif
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible<const int&>::value, true);
-// Following three tests may give different results because of copiler and C++03/C++11
+
+// Following three tests may give different results because of compiler and C++03/C++11.
+// On C++11 compiler following code:
+// int c[2][4][5][6][3];
+// int b[2][4][5][6][3] = std::move(c);
+// does not compile, so we expect `false` to be the result of those three tests.
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_copy_constructible<int[2]>::value, false, true);
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_copy_constructible<int[3][2]>::value, false, true);
BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_copy_constructible<int[2][4][5][6][3]>::value, false, true);
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