diff --git a/include/boost/type_traits/intrinsics.hpp b/include/boost/type_traits/intrinsics.hpp index dc831cb..5c86bcc 100644 --- a/include/boost/type_traits/intrinsics.hpp +++ b/include/boost/type_traits/intrinsics.hpp @@ -110,7 +110,7 @@ # if defined(_MSC_VER) && (_MSC_VER >= 1700) # define BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) (__has_trivial_move_constructor(T) || ( ::boost::is_pod::value && !::boost::is_volatile::value)) -# define BOOST_HAS_TRIVIAL_MOVE_ASSIGN(T) (__has_trivial_move_assign(T) || ( ::boost::is_pod::value && !::boost::is_volatile::value)) +# define BOOST_HAS_TRIVIAL_MOVE_ASSIGN(T) (__has_trivial_move_assign(T) || ( ::boost::is_pod::value && ! ::boost::is_const::value && !::boost::is_volatile::value)) # endif # define BOOST_HAS_TYPE_TRAITS_INTRINSICS diff --git a/include/boost/type_traits/is_nothrow_move_assignable.hpp b/include/boost/type_traits/is_nothrow_move_assignable.hpp index 33a9c6e..5a3427f 100644 --- a/include/boost/type_traits/is_nothrow_move_assignable.hpp +++ b/include/boost/type_traits/is_nothrow_move_assignable.hpp @@ -14,6 +14,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include // should be the last #include @@ -23,24 +29,44 @@ namespace boost { namespace detail{ +#ifndef BOOST_NO_CXX11_NOEXCEPT + +template +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() = ::boost::declval())>::type + > : public ::boost::integral_constant() = ::boost::declval())> +{}; + template struct is_nothrow_move_assignable_imp{ -#if 0 - // #ifndef BOOST_NO_CXX11_NOEXCEPT - BOOST_STATIC_CONSTANT(bool, value = ( - ::boost::type_traits::ice_or< - ::boost::has_trivial_move_assign::value, - BOOST_NOEXCEPT_EXPR(::boost::declval() = ::boost::declval()) + 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)); -#else - BOOST_STATIC_CONSTANT(bool, value = ( - ::boost::type_traits::ice_or< - ::boost::has_trivial_move_assign::value, - ::boost::has_nothrow_assign::value - >::value)); -#endif }; +#else + +template +struct is_nothrow_move_assignable_imp{ + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::type_traits::ice_and< + ::boost::type_traits::ice_or< + ::boost::has_trivial_move_assign::value, + ::boost::has_nothrow_assign::value + >::value, + ::boost::type_traits::ice_not< ::boost::is_array::value >::value + >::value)); +}; + +#endif + } BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_nothrow_move_assignable,T,::boost::detail::is_nothrow_move_assignable_imp::value) diff --git a/include/boost/type_traits/is_nothrow_move_constructible.hpp b/include/boost/type_traits/is_nothrow_move_constructible.hpp index b304dca..3781512 100644 --- a/include/boost/type_traits/is_nothrow_move_constructible.hpp +++ b/include/boost/type_traits/is_nothrow_move_constructible.hpp @@ -14,7 +14,10 @@ #include #include #include +#include +#include #include +#include #include // should be the last #include @@ -24,24 +27,44 @@ namespace boost { namespace detail{ +#ifndef BOOST_NO_CXX11_NOEXCEPT + +template +struct false_or_cpp11_noexcept_move_constructible: public ::boost::false_type {}; + +template +struct false_or_cpp11_noexcept_move_constructible < + T, + typename ::boost::enable_if_c()))>::type + > : public ::boost::integral_constant()))> +{}; + template struct is_nothrow_move_constructible_imp{ -#if 0 - //#ifndef BOOST_NO_CXX11_NOEXCEPT BOOST_STATIC_CONSTANT(bool, value = - (::boost::type_traits::ice_or< - ::boost::has_trivial_move_constructor::value, - BOOST_NOEXCEPT_EXPR(T(::boost::declval())) + (::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)); -#else - BOOST_STATIC_CONSTANT(bool, value = - (::boost::type_traits::ice_or< - ::boost::has_trivial_move_constructor::value, - ::boost::has_nothrow_copy::value - >::value)); -#endif }; +#else + +template +struct is_nothrow_move_constructible_imp{ + BOOST_STATIC_CONSTANT(bool, value =( + ::boost::type_traits::ice_and< + ::boost::type_traits::ice_or< + ::boost::has_trivial_move_constructor::value, + ::boost::has_nothrow_copy::value + >::value, + ::boost::type_traits::ice_not< ::boost::is_array::value >::value + >::value)); +}; + +#endif + } BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_nothrow_move_constructible,T,::boost::detail::is_nothrow_move_constructible_imp::value) diff --git a/test/is_nothrow_move_assignable_test.cpp b/test/is_nothrow_move_assignable_test.cpp index 4db943e..5cb2b1c 100644 --- a/test/is_nothrow_move_assignable_test.cpp +++ b/test/is_nothrow_move_assignable_test.cpp @@ -189,9 +189,9 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, fal BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, false); #endif BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable::value, false); -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, false); +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); 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 cc8fb62..6bfc167 100644 --- a/test/is_nothrow_move_constructible_test.cpp +++ b/test/is_nothrow_move_constructible_test.cpp @@ -186,9 +186,9 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible::value, false); #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, 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, false); +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); // cases we would like to succeed but can't implement in the language: