Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85458 - in trunk: boost/circular_buffer libs/circular_buffer/doc
From: antoshkka_at_[hidden]
Date: 2013-08-25 08:36:51


Author: apolukhin
Date: 2013-08-25 08:36:51 EDT (Sun, 25 Aug 2013)
New Revision: 85458
URL: http://svn.boost.org/trac/boost/changeset/85458

Log:
Make move_if_noexcept more strict and move values only if they have noexcept move constructor *and* noexcept move assignment operator (refs #7888)

Text files modified:
   trunk/boost/circular_buffer/base.hpp | 3 ++-
   trunk/libs/circular_buffer/doc/circular_buffer.qbk | 18 ++++++++----------
   2 files changed, 10 insertions(+), 11 deletions(-)

Modified: trunk/boost/circular_buffer/base.hpp
==============================================================================
--- trunk/boost/circular_buffer/base.hpp Sun Aug 25 08:27:04 2013 (r85457)
+++ trunk/boost/circular_buffer/base.hpp 2013-08-25 08:36:51 EDT (Sun, 25 Aug 2013) (r85458)
@@ -26,6 +26,7 @@
 #include <boost/type_traits/is_integral.hpp>
 #include <boost/type_traits/is_scalar.hpp>
 #include <boost/type_traits/is_nothrow_move_constructible.hpp>
+#include <boost/type_traits/is_nothrow_move_assignable.hpp>
 #include <boost/type_traits/is_copy_constructible.hpp>
 #include <boost/type_traits/conditional.hpp>
 #include <boost/move/move.hpp>
@@ -187,7 +188,7 @@
     /*! \cond */
     template <class ValT>
     static inline typename boost::conditional<
- (boost::is_nothrow_move_constructible<ValT>::value || !boost::is_copy_constructible<ValT>::value)
+ ((boost::is_nothrow_move_constructible<ValT>::value && boost::is_nothrow_move_assignable<ValT>::value) || !boost::is_copy_constructible<ValT>::value)
 #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) && defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
             && has_move_emulation_enabled<ValT>::value
 #endif

Modified: trunk/libs/circular_buffer/doc/circular_buffer.qbk
==============================================================================
--- trunk/libs/circular_buffer/doc/circular_buffer.qbk Sun Aug 25 08:27:04 2013 (r85457)
+++ trunk/libs/circular_buffer/doc/circular_buffer.qbk 2013-08-25 08:36:51 EDT (Sun, 25 Aug 2013) (r85458)
@@ -281,14 +281,14 @@
 * The containers themselves are not movable.
 * Argument forwarding is not perfect.
 
-__cb will use rvalues and move emulations for value types only if move constructor of the value type does not throw
+__cb will use rvalues and move emulations for value types only if move constructor and move assignment operator of the value type do not throw;
 or if the value type has no copy constructor.
 
 Some methods won't use move constructor for the value type at all, if the constructor throws. This is
 required for data consistency and avoidance of situations, when aftrer an exception __cb
 contains moved away objects along with the good ones.
 
-See documentation for [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html `is_copy_constructible`] and [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_constructible.html `is_nothrow_move_constructible`] type triats.
+See documentation for [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html `is_copy_constructible`], [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_assignable.html `is_nothrow_move_assignable`] and [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_constructible.html `is_nothrow_move_constructible`] type triats.
 There you'll find information about how to make constructor of class noexcept and how to make a non-copyable
 class in C++03 and C++98.
 
@@ -298,18 +298,16 @@
 
 Reference documentation of the __cb contains notes like "Throws: See Exceptions of `move_if_noexcept(T&)`".
 That note means the following: `move_if_noexcept(T& value)` does not throws exceptions at all, but it returns
-`value` as rvalue reference only if class `T` have noexcept move constructor or if it has no copy constructor.
-Otherwise `move_if_noexcept(T& value)` returns `value` as const reference.
+`value` as rvalue reference only if class `T` have noexcept move constructor and noexcept move assignment operator;
+or if it has no copy constructor. Otherwise `move_if_noexcept(T& value)` returns `value` as const reference.
 
 This leads us to the following situation:
 
-* If `value` has a noexcept move constructor, then no exceptions will be thrown at all.
-* If `value` has a throwing move constructor and some copy constructor, then method may throw exceptions
-of copy constructor.
-* If `value` has a throwing move constructor and no copy constructor, then method may throw exceptions
-of move constructor.
+* If `value` has a noexcept move constructor and noexcept move assignment operator, then no exceptions will be thrown at all.
+* If `value` has a throwing move constructor and some copy constructor, then method may throw exceptions of copy constructor.
+* If `value` has no copy constructor, then method may throw exceptions of move constructor.
 
-`move_if_noexcept(T&)` uses [@boost:libs/move/doc/html/move.html Boost.Move], [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html `is_copy_constructible`] and [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_constructible.html `is_nothrow_move_constructible`] type triats.
+`move_if_noexcept(T&)` uses [@boost:libs/move/doc/html/move.html Boost.Move], [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html `is_copy_constructible`], [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_assignable.html `is_nothrow_move_assignable`] and [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_constructible.html `is_nothrow_move_constructible`] type triats.
 
 
 [h3 Caveats]


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