From ae76223babe2e088ef444f8d39494d99e3fa3f28 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Thu, 11 Jun 2015 11:26:33 +0100 Subject: [PATCH] Move trivial/nothrow construct traits closer into line with the standard. --- .../type_traits/has_trivial_move_constructor.hpp | 8 ++++++++ .../type_traits/is_nothrow_move_constructible.hpp | 13 +++++-------- test/has_trivial_move_constructor_test.cpp | 12 ++++++------ test/is_nothrow_move_constructible_test.cpp | 6 +++--- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/include/boost/type_traits/has_trivial_move_constructor.hpp b/include/boost/type_traits/has_trivial_move_constructor.hpp index 1a032a9..e37dfe3 100644 --- a/include/boost/type_traits/has_trivial_move_constructor.hpp +++ b/include/boost/type_traits/has_trivial_move_constructor.hpp @@ -48,6 +48,14 @@ template <> struct has_trivial_move_constructor : public false_type{ template <> struct has_trivial_move_constructor : public false_type{}; template <> struct has_trivial_move_constructor : public false_type{}; #endif +// What should we do with reference types??? The standard seems to suggest these are trivial, even if the thing they reference is not: +template struct has_trivial_move_constructor : public true_type{}; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +template struct has_trivial_move_constructor : public true_type{}; +#endif +// Arrays can not be explicitly copied: +template struct has_trivial_move_constructor : public false_type{}; +template struct has_trivial_move_constructor : public false_type{}; } // namespace boost diff --git a/include/boost/type_traits/is_nothrow_move_constructible.hpp b/include/boost/type_traits/is_nothrow_move_constructible.hpp index 323f443..4b7a71b 100644 --- a/include/boost/type_traits/is_nothrow_move_constructible.hpp +++ b/include/boost/type_traits/is_nothrow_move_constructible.hpp @@ -24,10 +24,6 @@ struct is_nothrow_move_constructible : public integral_constant struct is_nothrow_move_constructible : public ::boost::false_type {}; template struct is_nothrow_move_constructible : public ::boost::false_type{}; -template struct is_nothrow_move_constructible : public ::boost::false_type{}; -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -template struct is_nothrow_move_constructible : public ::boost::false_type{}; -#endif #elif !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) @@ -53,10 +49,6 @@ template struct is_nothrow_move_constructible template struct is_nothrow_move_constructible : public ::boost::false_type {}; template struct is_nothrow_move_constructible : public ::boost::false_type{}; -template struct is_nothrow_move_constructible : public ::boost::false_type{}; -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -template struct is_nothrow_move_constructible : public ::boost::false_type{}; -#endif #else @@ -80,6 +72,11 @@ template <> struct is_nothrow_move_constructible : false_type{}; template <> struct is_nothrow_move_constructible : false_type{}; template <> struct is_nothrow_move_constructible : false_type{}; #endif +// References are always trivially constructible, even if the thing they reference is not: +template struct is_nothrow_move_constructible : public ::boost::true_type{}; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +template struct is_nothrow_move_constructible : public ::boost::true_type{}; +#endif } // namespace boost diff --git a/test/has_trivial_move_constructor_test.cpp b/test/has_trivial_move_constructor_test.cpp index 1071f1b..c34c834 100644 --- a/test/has_trivial_move_constructor_test.cpp +++ b/test/has_trivial_move_constructor_test.cpp @@ -210,14 +210,14 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, tru BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); #endif -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_move_constructor::value, false); // cases we would like to succeed but can't implement in the language: diff --git a/test/is_nothrow_move_constructible_test.cpp b/test/is_nothrow_move_constructible_test.cpp index a15cacf..7a196ed 100644 --- a/test/is_nothrow_move_constructible_test.cpp +++ b/test/is_nothrow_move_constructible_test.cpp @@ -182,11 +182,11 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, tr BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true); -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true); #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true); #endif -BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false);