From 26aecaa3c8d07c33b55a940cd0dd497437875c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 24 Aug 2013 10:34:37 +0000 Subject: [PATCH] First Move merge for 1.55 [SVN r85442] --- doc/move.qbk | 27 +++++++++++++++++++++------ example/doc_file_descriptor.cpp | 13 +++++++------ include/boost/move/algorithm.hpp | 1 - include/boost/move/core.hpp | 7 +++++++ include/boost/move/traits.hpp | 12 ++++++++++-- include/boost/move/utility.hpp | 22 +++++++++++----------- test/move.cpp | 1 - 7 files changed, 56 insertions(+), 27 deletions(-) diff --git a/doc/move.qbk b/doc/move.qbk index e1d61ae..64328be 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -129,9 +129,12 @@ Consider a simple handle class that owns a resource and also provides copy seman clone_ptr& operator=(clone_ptr&& p) { - std::swap(ptr, p.ptr); - delete p.ptr; - p.ptr = 0; + if(this != &p) + { + std::swap(ptr, p.ptr); + delete p.ptr; + p.ptr = 0; + } return *this; } @@ -171,7 +174,7 @@ You just need to follow these simple steps: * Put the following macro in the [*private] section: [macroref BOOST_COPYABLE_AND_MOVABLE BOOST_COPYABLE_AND_MOVABLE(classname)] -* Left copy constructor as is. +* Leave copy constructor as is. * Write a copy assignment taking the parameter as [macroref BOOST_COPY_ASSIGN_REF BOOST_COPY_ASSIGN_REF(classname)] * Write a move constructor and a move assignment taking the parameter as @@ -787,10 +790,22 @@ Many thanks to all boosters that have tested, reviewed and improved the library. [section:release_notes Release Notes] +[section:release_notes_boost_1_55_00 Boost 1.55 Release] + +* Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7952 #7952], + [@https://svn.boost.org/trac/boost/ticket/8764 #8764], + [@https://svn.boost.org/trac/boost/ticket/8765 #8765], + [@https://svn.boost.org/trac/boost/ticket/8842 #8842], + [@https://svn.boost.org/trac/boost/ticket/8979 #8979]. +[endsect] + + [section:release_notes_boost_1_54_00 Boost 1.54 Release] -* Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7969 #7969]), - [@https://svn.boost.org/trac/boost/ticket/8231 #8231]). + +* Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7969 #7969], + [@https://svn.boost.org/trac/boost/ticket/8231 #8231], + [@https://svn.boost.org/trac/boost/ticket/8765 #8765]. [endsect] diff --git a/example/doc_file_descriptor.cpp b/example/doc_file_descriptor.cpp index e4e6ba3..1dd7bc0 100644 --- a/example/doc_file_descriptor.cpp +++ b/example/doc_file_descriptor.cpp @@ -10,6 +10,7 @@ ////////////////////////////////////////////////////////////////////////////// #include +#include //[file_descriptor_def @@ -24,8 +25,8 @@ class file_descriptor return 1; } - void operating_system_close_file(int) - {} + void operating_system_close_file(int fd) + { (void)fd; assert(fd != 0); } //-> int os_descr_; @@ -33,12 +34,12 @@ class file_descriptor BOOST_MOVABLE_BUT_NOT_COPYABLE(file_descriptor) public: - explicit file_descriptor(const char *filename = 0) //Constructor - : os_descr_(filename ? operating_system_open_file(filename) : 0) + explicit file_descriptor(const char *filename) //Constructor + : os_descr_(operating_system_open_file(filename)) { if(!os_descr_) throw std::runtime_error("file not found"); } ~file_descriptor() //Destructor - { if(!os_descr_) operating_system_close_file(os_descr_); } + { if(os_descr_) operating_system_close_file(os_descr_); } file_descriptor(BOOST_RV_REF(file_descriptor) x) // Move ctor : os_descr_(x.os_descr_) @@ -46,7 +47,7 @@ class file_descriptor file_descriptor& operator=(BOOST_RV_REF(file_descriptor) x) // Move assign { - if(!os_descr_) operating_system_close_file(os_descr_); + if(os_descr_) operating_system_close_file(os_descr_); os_descr_ = x.os_descr_; x.os_descr_ = 0; return *this; diff --git a/include/boost/move/algorithm.hpp b/include/boost/move/algorithm.hpp index 36a46be..43a81c3 100644 --- a/include/boost/move/algorithm.hpp +++ b/include/boost/move/algorithm.hpp @@ -18,7 +18,6 @@ #include #include -#include #include #include //copy, copy_backward diff --git a/include/boost/move/core.hpp b/include/boost/move/core.hpp index d939f03..9586eca 100644 --- a/include/boost/move/core.hpp +++ b/include/boost/move/core.hpp @@ -18,17 +18,24 @@ #include +//boost_move_no_copy_constructor_or_assign typedef +//used to detect noncopyable types for other Boost libraries. #ifdef BOOST_NO_CXX11_DELETED_FUNCTIONS #define BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE) \ private:\ TYPE(TYPE &);\ TYPE& operator=(TYPE &);\ + public:\ + typedef int boost_move_no_copy_constructor_or_assign; \ + private:\ // #else #define BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE) \ public:\ TYPE(TYPE const &) = delete;\ TYPE& operator=(TYPE const &) = delete;\ + public:\ + typedef int boost_move_no_copy_constructor_or_assign; \ private:\ // #endif //BOOST_NO_CXX11_DELETED_FUNCTIONS diff --git a/include/boost/move/traits.hpp b/include/boost/move/traits.hpp index e5c8444..ced1cdd 100644 --- a/include/boost/move/traits.hpp +++ b/include/boost/move/traits.hpp @@ -16,6 +16,8 @@ #include #include +#include +#include #include #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES @@ -38,11 +40,17 @@ struct has_trivial_destructor_after_move : ::boost::has_trivial_destructor {}; -//! By default this traits returns false. Classes with non-throwing move constructor +//! By default this traits returns +//!
boost::is_nothrow_move_constructible::value && boost::is_nothrow_move_assignable::value 
. +//! Classes with non-throwing move constructor //! and assignment can specialize this trait to obtain some performance improvements. template struct has_nothrow_move - : public ::boost::move_detail::integral_constant + : public ::boost::move_detail::integral_constant + < bool + , boost::is_nothrow_move_constructible::value && + boost::is_nothrow_move_assignable::value + > {}; namespace move_detail { diff --git a/include/boost/move/utility.hpp b/include/boost/move/utility.hpp index fb2ec69..964500e 100644 --- a/include/boost/move/utility.hpp +++ b/include/boost/move/utility.hpp @@ -37,7 +37,7 @@ template inline typename ::boost::move_detail::enable_if_c < enable_move_utility_emulation::value && !has_move_emulation_enabled::value, T&>::type - move(T& x) + move(T& x) BOOST_NOEXCEPT { return x; } @@ -45,7 +45,7 @@ template inline typename ::boost::move_detail::enable_if_c < enable_move_utility_emulation::value && has_move_emulation_enabled::value, rv&>::type - move(T& x) + move(T& x) BOOST_NOEXCEPT { return *static_cast* >(::boost::move_detail::addressof(x)); } @@ -53,7 +53,7 @@ template inline typename ::boost::move_detail::enable_if_c < enable_move_utility_emulation::value && has_move_emulation_enabled::value, rv&>::type - move(rv& x) + move(rv& x) BOOST_NOEXCEPT { return x; } @@ -67,7 +67,7 @@ template inline typename ::boost::move_detail::enable_if_c < enable_move_utility_emulation::value && ::boost::move_detail::is_rv::value, T &>::type - forward(const typename ::boost::move_detail::identity::type &x) + forward(const typename ::boost::move_detail::identity::type &x) BOOST_NOEXCEPT { return const_cast(x); } @@ -75,7 +75,7 @@ template inline typename ::boost::move_detail::enable_if_c < enable_move_utility_emulation::value && !::boost::move_detail::is_rv::value, const T &>::type - forward(const typename ::boost::move_detail::identity::type &x) + forward(const typename ::boost::move_detail::identity::type &x) BOOST_NOEXCEPT { return x; } @@ -123,19 +123,19 @@ //! in compilers with rvalue references. For other compilers converts T & into //! ::boost::rv & so that move emulation is activated. template - rvalue_reference move (input_reference); + rvalue_reference move(input_reference) noexcept; #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) //Old move approach, lvalues could bind to rvalue references template - inline typename remove_reference::type && move(T&& t) + inline typename remove_reference::type && move(T&& t) BOOST_NOEXCEPT { return t; } #else //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES template - inline typename remove_reference::type && move(T&& t) + inline typename remove_reference::type && move(T&& t) BOOST_NOEXCEPT { return static_cast::type &&>(t); } #endif //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES @@ -159,13 +159,13 @@ //! ::boost::rv & //! //! * Else, output_reference is equal to input_reference. - template output_reference forward(input_reference); + template output_reference forward(input_reference) noexcept; #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) //Old move approach, lvalues could bind to rvalue references template - inline T&& forward (typename ::boost::move_detail::identity::type&& t) + inline T&& forward(typename ::boost::move_detail::identity::type&& t) BOOST_NOEXCEPT { return t; } #else //Old move @@ -178,7 +178,7 @@ move_detail::is_lvalue_reference::value ? move_detail::is_lvalue_reference::value : true>::type * = 0/* , typename ::boost::move_detail::enable_if_c< move_detail::is_convertible - ::type*, typename remove_reference::type*>::value>::type * = 0*/) + ::type*, typename remove_reference::type*>::value>::type * = 0*/) BOOST_NOEXCEPT { return static_cast(t); } #endif //BOOST_MOVE_DOXYGEN_INVOKED diff --git a/test/move.cpp b/test/move.cpp index a48b4ef..4d6eae7 100644 --- a/test/move.cpp +++ b/test/move.cpp @@ -66,7 +66,6 @@ int main() { #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) BOOST_STATIC_ASSERT((boost::has_nothrow_move::value == true)); - BOOST_STATIC_ASSERT((boost::has_nothrow_move::value == false)); BOOST_STATIC_ASSERT((boost::has_move_emulation_enabled::value == false)); BOOST_STATIC_ASSERT((boost::has_move_emulation_enabled::value == false)); BOOST_STATIC_ASSERT((boost::has_move_emulation_enabled::value == false));