|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83245 - in trunk: boost/type_traits libs/type_traits/test
From: antoshkka_at_[hidden]
Date: 2013-03-02 11:15:32
Author: apolukhin
Date: 2013-03-02 11:15:30 EST (Sat, 02 Mar 2013)
New Revision: 83245
URL: http://svn.boost.org/trac/boost/changeset/83245
Log:
Fix MSVC11 test (refs #8189).
Added C++11 noexcept implementation of is_nothrow_move_constructible and is_nothrow_move_assignable traits and changed C++03 version to to work close to C++11 (refs #8189).
Text files modified:
trunk/boost/type_traits/intrinsics.hpp | 2
trunk/boost/type_traits/is_nothrow_move_assignable.hpp | 48 ++++++++++++++++++++++++++++++---------
trunk/boost/type_traits/is_nothrow_move_constructible.hpp | 43 +++++++++++++++++++++++++++--------
trunk/libs/type_traits/test/is_nothrow_move_assignable_test.cpp | 6 ++--
trunk/libs/type_traits/test/is_nothrow_move_constructible_test.cpp | 6 ++--
5 files changed, 77 insertions(+), 28 deletions(-)
Modified: trunk/boost/type_traits/intrinsics.hpp
==============================================================================
--- trunk/boost/type_traits/intrinsics.hpp (original)
+++ trunk/boost/type_traits/intrinsics.hpp 2013-03-02 11:15:30 EST (Sat, 02 Mar 2013)
@@ -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<T>::value && !::boost::is_volatile<T>::value))
-# define BOOST_HAS_TRIVIAL_MOVE_ASSIGN(T) (__has_trivial_move_assign(T) || ( ::boost::is_pod<T>::value && !::boost::is_volatile<T>::value))
+# define BOOST_HAS_TRIVIAL_MOVE_ASSIGN(T) (__has_trivial_move_assign(T) || ( ::boost::is_pod<T>::value && ! ::boost::is_const<T>::value && !::boost::is_volatile<T>::value))
# endif
# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
Modified: trunk/boost/type_traits/is_nothrow_move_assignable.hpp
==============================================================================
--- trunk/boost/type_traits/is_nothrow_move_assignable.hpp (original)
+++ trunk/boost/type_traits/is_nothrow_move_assignable.hpp 2013-03-02 11:15:30 EST (Sat, 02 Mar 2013)
@@ -14,6 +14,12 @@
#include <boost/config.hpp>
#include <boost/type_traits/has_trivial_move_assign.hpp>
#include <boost/type_traits/has_nothrow_assign.hpp>
+#include <boost/type_traits/is_array.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/detail/ice_and.hpp>
+#include <boost/type_traits/detail/ice_or.hpp>
+#include <boost/type_traits/detail/ice_not.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/utility/declval.hpp>
// should be the last #include
@@ -23,24 +29,44 @@
namespace detail{
+#ifndef BOOST_NO_CXX11_NOEXCEPT
+
+template <class T, class Enable = void>
+struct false_or_cpp11_noexcept_move_assignable: public ::boost::false_type {};
+
+template <class T>
+struct false_or_cpp11_noexcept_move_assignable <
+ T,
+ typename ::boost::enable_if_c<sizeof(T) && BOOST_NOEXCEPT_EXPR(::boost::declval<T&>() = ::boost::declval<T>())>::type
+ > : public ::boost::integral_constant<bool, BOOST_NOEXCEPT_EXPR(::boost::declval<T&>() = ::boost::declval<T>())>
+{};
+
template <class T>
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<T>::value,
- BOOST_NOEXCEPT_EXPR(::boost::declval<T>() = ::boost::declval<T>())
+ BOOST_STATIC_CONSTANT(bool, value = (
+ ::boost::type_traits::ice_and<
+ ::boost::type_traits::ice_not< ::boost::is_volatile<T>::value >::value,
+ ::boost::type_traits::ice_not< ::boost::is_reference<T>::value >::value,
+ ::boost::detail::false_or_cpp11_noexcept_move_assignable<T>::value
>::value));
+};
+
#else
- BOOST_STATIC_CONSTANT(bool, value = (
- ::boost::type_traits::ice_or<
- ::boost::has_trivial_move_assign<T>::value,
- ::boost::has_nothrow_assign<T>::value
+
+template <class T>
+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<T>::value,
+ ::boost::has_nothrow_assign<T>::value
+ >::value,
+ ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value
>::value));
-#endif
};
+#endif
+
}
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_nothrow_move_assignable,T,::boost::detail::is_nothrow_move_assignable_imp<T>::value)
Modified: trunk/boost/type_traits/is_nothrow_move_constructible.hpp
==============================================================================
--- trunk/boost/type_traits/is_nothrow_move_constructible.hpp (original)
+++ trunk/boost/type_traits/is_nothrow_move_constructible.hpp 2013-03-02 11:15:30 EST (Sat, 02 Mar 2013)
@@ -14,7 +14,10 @@
#include <boost/config.hpp>
#include <boost/type_traits/has_trivial_move_constructor.hpp>
#include <boost/type_traits/has_nothrow_copy.hpp>
+#include <boost/type_traits/is_array.hpp>
+#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
+#include <boost/type_traits/detail/ice_and.hpp>
#include <boost/utility/declval.hpp>
// should be the last #include
@@ -24,24 +27,44 @@
namespace detail{
+#ifndef BOOST_NO_CXX11_NOEXCEPT
+
+template <class T, class Enable = void>
+struct false_or_cpp11_noexcept_move_constructible: public ::boost::false_type {};
+
+template <class T>
+struct false_or_cpp11_noexcept_move_constructible <
+ T,
+ typename ::boost::enable_if_c<sizeof(T) && BOOST_NOEXCEPT_EXPR(T(::boost::declval<T>()))>::type
+ > : public ::boost::integral_constant<bool, BOOST_NOEXCEPT_EXPR(T(::boost::declval<T>()))>
+{};
+
template <class T>
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<T>::value,
- BOOST_NOEXCEPT_EXPR(T(::boost::declval<T>()))
+ (::boost::type_traits::ice_and<
+ ::boost::type_traits::ice_not< ::boost::is_volatile<T>::value >::value,
+ ::boost::type_traits::ice_not< ::boost::is_reference<T>::value >::value,
+ ::boost::detail::false_or_cpp11_noexcept_move_constructible<T>::value
>::value));
+};
+
#else
- BOOST_STATIC_CONSTANT(bool, value =
- (::boost::type_traits::ice_or<
- ::boost::has_trivial_move_constructor<T>::value,
- ::boost::has_nothrow_copy<T>::value
+
+template <class T>
+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<T>::value,
+ ::boost::has_nothrow_copy<T>::value
+ >::value,
+ ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value
>::value));
-#endif
};
+#endif
+
}
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_nothrow_move_constructible,T,::boost::detail::is_nothrow_move_constructible_imp<T>::value)
Modified: trunk/libs/type_traits/test/is_nothrow_move_assignable_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/is_nothrow_move_assignable_test.cpp (original)
+++ trunk/libs/type_traits/test/is_nothrow_move_assignable_test.cpp 2013-03-02 11:15:30 EST (Sat, 02 Mar 2013)
@@ -189,9 +189,9 @@
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<int&&>::value, false);
#endif
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<const int&>::value, false);
-BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<int[2]>::value, true);
-BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<int[3][2]>::value, true);
-BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<int[2][4][5][6][3]>::value, true);
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<int[2]>::value, false);
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<int[3][2]>::value, false);
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<int[2][4][5][6][3]>::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<UDT>::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<empty_UDT>::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_assignable<void>::value, false);
Modified: trunk/libs/type_traits/test/is_nothrow_move_constructible_test.cpp
==============================================================================
--- trunk/libs/type_traits/test/is_nothrow_move_constructible_test.cpp (original)
+++ trunk/libs/type_traits/test/is_nothrow_move_constructible_test.cpp 2013-03-02 11:15:30 EST (Sat, 02 Mar 2013)
@@ -186,9 +186,9 @@
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<int&&>::value, false);
#endif
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<const int&>::value, false);
-BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<int[2]>::value, true);
-BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<int[3][2]>::value, true);
-BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<int[2][4][5][6][3]>::value, true);
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<int[2]>::value, false);
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<int[3][2]>::value, false);
+BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<int[2][4][5][6][3]>::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<UDT>::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_nothrow_move_constructible<void>::value, false);
// cases we would like to succeed but can't implement in the language:
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