diff --git a/include/boost/type_traits/is_copy_constructible.hpp b/include/boost/type_traits/is_copy_constructible.hpp index 032ad2b..4e87131 100644 --- a/include/boost/type_traits/is_copy_constructible.hpp +++ b/include/boost/type_traits/is_copy_constructible.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -67,9 +68,11 @@ struct is_copy_constructible_impl2 { // ... // }; BOOST_STATIC_CONSTANT(bool, value = ( - sizeof(test( - boost::declval::type>() - )) == sizeof(boost::type_traits::yes_type) + sizeof(test( + boost::declval::type>() + )) == sizeof(boost::type_traits::yes_type) + || + boost::is_rvalue_reference::value )); }; diff --git a/test/is_copy_constructible_test.cpp b/test/is_copy_constructible_test.cpp index 7cca73a..0ab0a9f 100644 --- a/test/is_copy_constructible_test.cpp +++ b/test/is_copy_constructible_test.cpp @@ -259,11 +259,27 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible::value, true BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible::value, true); #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible::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::value, true); #endif BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_copy_constructible::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::value, false, true); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_copy_constructible::value, false, true); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_copy_constructible::value, false, true);