From 5c0474dbc7d6ed28bacf64348139814d13bd8097 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 19 Oct 2014 17:45:57 +0100 Subject: [PATCH 1/2] Improve is_nothrow* tests. Disable is_nothrow* full implementation when there's no SFINAE expressions and simplify implementation. --- .../is_nothrow_move_assignable.hpp | 23 ++++++++++++------- .../is_nothrow_move_constructible.hpp | 9 +++++++- test/is_nothrow_move_assignable_test.cpp | 8 +++++++ test/is_nothrow_move_constructible_test.cpp | 8 +++++++ 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/include/boost/type_traits/is_nothrow_move_assignable.hpp b/include/boost/type_traits/is_nothrow_move_assignable.hpp index c55dfc6..2ee0e45 100644 --- a/include/boost/type_traits/is_nothrow_move_assignable.hpp +++ b/include/boost/type_traits/is_nothrow_move_assignable.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -30,7 +29,7 @@ namespace boost { namespace detail{ -#ifndef BOOST_NO_CXX11_NOEXCEPT +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) template struct false_or_cpp11_noexcept_move_assignable: public ::boost::false_type {}; @@ -44,14 +43,22 @@ struct false_or_cpp11_noexcept_move_assignable < template struct is_nothrow_move_assignable_imp{ - BOOST_STATIC_CONSTANT(bool, value = ( - ::boost::type_traits::ice_and< - ::boost::type_traits::ice_not< ::boost::is_volatile::value >::value, - ::boost::type_traits::ice_not< ::boost::is_reference::value >::value, - ::boost::detail::false_or_cpp11_noexcept_move_assignable::value - >::value)); + BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::false_or_cpp11_noexcept_move_assignable::value); }; +template +struct is_nothrow_move_assignable_imp : public ::boost::false_type {}; +template +struct is_nothrow_move_assignable_imp : public ::boost::false_type{}; +template +struct is_nothrow_move_assignable_imp : public ::boost::false_type{}; +template +struct is_nothrow_move_assignable_imp : public ::boost::false_type{}; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +template +struct is_nothrow_move_assignable_imp : public ::boost::false_type{}; +#endif + #else template diff --git a/include/boost/type_traits/is_nothrow_move_constructible.hpp b/include/boost/type_traits/is_nothrow_move_constructible.hpp index bc7fb88..e557da3 100644 --- a/include/boost/type_traits/is_nothrow_move_constructible.hpp +++ b/include/boost/type_traits/is_nothrow_move_constructible.hpp @@ -28,7 +28,7 @@ namespace boost { namespace detail{ -#ifndef BOOST_NO_CXX11_NOEXCEPT +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) template struct false_or_cpp11_noexcept_move_constructible: public ::boost::false_type {}; @@ -50,6 +50,13 @@ struct is_nothrow_move_constructible_imp{ >::value)); }; +template +struct is_nothrow_move_constructible_imp : public ::boost::false_type {}; +template +struct is_nothrow_move_constructible_imp : public ::boost::false_type{}; +template +struct is_nothrow_move_constructible_imp : public ::boost::false_type{}; + #else template diff --git a/test/is_nothrow_move_assignable_test.cpp b/test/is_nothrow_move_assignable_test.cpp index 2202701..7522a6e 100644 --- a/test/is_nothrow_move_assignable_test.cpp +++ b/test/is_nothrow_move_assignable_test.cpp @@ -195,12 +195,20 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, false); +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true); +#else // cases we would like to succeed but can't implement in the language: BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, true, false); +#endif BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, false); diff --git a/test/is_nothrow_move_constructible_test.cpp b/test/is_nothrow_move_constructible_test.cpp index e17c3fd..6f6ccfb 100644 --- a/test/is_nothrow_move_constructible_test.cpp +++ b/test/is_nothrow_move_constructible_test.cpp @@ -191,12 +191,20 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::va 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); +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) +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, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true); +#else // cases we would like to succeed but can't implement in the language: BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true, false); BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, true, false); +#endif BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); From 9ad41f9ff6dbf7c0220a2ff87d4cce7cc94bca78 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 20 Oct 2014 11:50:47 +0100 Subject: [PATCH 2/2] Remove unneeded is_const. Tidy up special cases. --- .../boost/type_traits/is_nothrow_move_assignable.hpp | 2 +- .../type_traits/is_nothrow_move_constructible.hpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/boost/type_traits/is_nothrow_move_assignable.hpp b/include/boost/type_traits/is_nothrow_move_assignable.hpp index 2ee0e45..7acbcce 100644 --- a/include/boost/type_traits/is_nothrow_move_assignable.hpp +++ b/include/boost/type_traits/is_nothrow_move_assignable.hpp @@ -37,7 +37,7 @@ struct false_or_cpp11_noexcept_move_assignable: public ::boost::false_type {}; template struct false_or_cpp11_noexcept_move_assignable < T, - typename ::boost::enable_if_c::value && BOOST_NOEXCEPT_EXPR(::boost::declval() = ::boost::declval())>::type + typename ::boost::enable_if_c() = ::boost::declval())>::type > : public ::boost::integral_constant() = ::boost::declval())> {}; diff --git a/include/boost/type_traits/is_nothrow_move_constructible.hpp b/include/boost/type_traits/is_nothrow_move_constructible.hpp index e557da3..b8a657a 100644 --- a/include/boost/type_traits/is_nothrow_move_constructible.hpp +++ b/include/boost/type_traits/is_nothrow_move_constructible.hpp @@ -42,12 +42,7 @@ struct false_or_cpp11_noexcept_move_constructible < template struct is_nothrow_move_constructible_imp{ - BOOST_STATIC_CONSTANT(bool, value = - (::boost::type_traits::ice_and< - ::boost::type_traits::ice_not< ::boost::is_volatile::value >::value, - ::boost::type_traits::ice_not< ::boost::is_reference::value >::value, - ::boost::detail::false_or_cpp11_noexcept_move_constructible::value - >::value)); + BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::false_or_cpp11_noexcept_move_constructible::value); }; template @@ -56,6 +51,10 @@ template struct is_nothrow_move_constructible_imp : public ::boost::false_type{}; template struct is_nothrow_move_constructible_imp : public ::boost::false_type{}; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +template +struct is_nothrow_move_constructible_imp : public ::boost::false_type{}; +#endif #else