From 4dacaf7befe1779989f22455833a4cc170a86d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 6 Sep 2011 11:44:20 +0000 Subject: [PATCH 01/26] Fixed error with convertible types in move helpers [SVN r74260] --- include/boost/move/move.hpp | 6 +++--- include/boost/move/move_helpers.hpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 86cd032..0a289fc 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -121,7 +121,7 @@ class false_t { char dummy[2]; }; static true_t dispatch(U); static false_t dispatch(...); - static T trigger(); + static T &trigger(); public: enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; }; @@ -718,13 +718,13 @@ namespace move_detail { template struct is_move_iterator - : public BOOST_MOVE_MPL_NS::integral_constant + : public BOOST_MOVE_BOOST_NS::integral_constant { }; template struct is_move_iterator< ::boost::move_iterator > - : public BOOST_MOVE_MPL_NS::integral_constant + : public BOOST_MOVE_BOOST_NS::integral_constant { }; diff --git a/include/boost/move/move_helpers.hpp b/include/boost/move/move_helpers.hpp index 92e052e..eaf51d6 100644 --- a/include/boost/move/move_helpers.hpp +++ b/include/boost/move/move_helpers.hpp @@ -27,9 +27,9 @@ #if defined(BOOST_NO_RVALUE_REFERENCES) struct not_a_type; #define BOOST_MOVE_CATCH_CONST(U) \ - typename ::boost::mpl::if_< ::boost::is_class, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type + typename ::boost::mpl::if_< ::boost::is_class, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type #define BOOST_MOVE_CATCH_RVALUE(U)\ - typename ::boost::mpl::if_< ::boost::is_class, BOOST_RV_REF(T), not_a_type>::type + typename ::boost::mpl::if_< ::boost::is_class, BOOST_RV_REF(U), not_a_type>::type #define BOOST_MOVE_CATCH_FWD(U) BOOST_FWD_REF(U) #else #define BOOST_MOVE_CATCH_CONST(U) const U & @@ -60,9 +60,9 @@ struct not_a_type; \ template\ typename ::boost::enable_if_c\ - < ::boost::is_class::value &&\ - !::boost::is_same::value &&\ - !::boost::move_detail::is_rv::value\ + < (!::boost::is_class::value || \ + !::boost::move_detail::is_rv::value) && \ + !::boost::is_same::value \ , RETURN_VALUE >::type\ PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ {\ @@ -127,9 +127,9 @@ struct not_a_type; \ template\ typename ::boost::enable_if_c\ - < ::boost::is_class::value &&\ - !::boost::is_same::value &&\ - !::boost::move_detail::is_rv::value\ + < (!::boost::is_class::value || \ + !::boost::move_detail::is_rv::value) && \ + !::boost::is_same::value \ , RETURN_VALUE >::type\ PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ {\ From 52530c4b74929812801900e327d4facb87a9c0c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 8 Sep 2011 06:57:58 +0000 Subject: [PATCH 02/26] Documentation fixes [SVN r74305] --- include/boost/move/move.hpp | 58 +++++++++++++++---------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 0a289fc..87d63c6 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -15,6 +15,8 @@ #ifndef BOOST_MOVE_MOVE_HPP #define BOOST_MOVE_MOVE_HPP +#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + /// @cond #include @@ -206,6 +208,8 @@ /// @endcond +#endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) //Move emulation rv breaks standard aliasing rules so add workarounds for some compilers @@ -508,21 +512,6 @@ #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) - ////////////////////////////////////////////////////////////////////////////// - // - // BOOST_ENABLE_MOVE_EMULATION - // - ////////////////////////////////////////////////////////////////////////////// - - ///@cond - - #define BOOST_ENABLE_MOVE_EMULATION(TYPE)\ - typedef int boost_move_emulation_t; - \ - // - - /// @endcond - //! This macro marks a type as movable but not copyable, disabling copy construction //! and assignment. The user will need to write a move constructor/assignment as explained //! in the documentation to fully write a movable but not copyable class. @@ -540,18 +529,9 @@ #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\ // - /// @cond - - #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ - TYPE && \ + #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\ // - #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ - TYPE && \ - // - - /// @endcond - //!This macro is used to achieve portable syntax in move //!constructors and assignments for classes marked as //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE @@ -565,8 +545,24 @@ const TYPE & \ // + //! This macro is used to implement portable perfect forwarding + //! as explained in the documentation. + #define BOOST_FWD_REF(TYPE)\ + TYPE && \ + // + + + #if !defined(BOOST_MOVE_DOXYGEN_INVOKED) /// @cond + #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ + TYPE && \ + // + + #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ + TYPE && \ + // + #define BOOST_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ const TYPE & \ // @@ -575,22 +571,14 @@ TYPE& \ // - /// @endcond - - //! This macro is used to implement portable perfect forwarding - //! as explained in the documentation. - #define BOOST_FWD_REF(TYPE)\ - TYPE && \ - // - - /// @cond - #define BOOST_CATCH_CONST_RLVALUE(TYPE)\ const TYPE & \ // /// @endcond + #endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + #endif //BOOST_NO_RVALUE_REFERENCES namespace boost { From 59ffb87b9d02691ffd4f7940f84e8433c6a434ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 8 Sep 2011 06:58:18 +0000 Subject: [PATCH 03/26] Documentation fixes [SVN r74306] --- doc/Jamfile.v2 | 2 +- doc/move.qbk | 8 ++++---- example/doc_clone_ptr.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index f970d61..55c1702 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -13,7 +13,7 @@ import quickbook ; doxygen autodoc : - [ glob ../../../boost/move/*.hpp ] + [ glob ../../../boost/move/move.hpp ] : HIDE_UNDOC_MEMBERS=YES HIDE_UNDOC_MEMBERS=YES diff --git a/doc/move.qbk b/doc/move.qbk index 1275a56..5cc8a99 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -717,10 +717,10 @@ operators to references to `::boost::rv`: #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ public:\ - operator ::BOOST_MOVE_NAMESPACE::rv&() \ - { return *reinterpret_cast< ::BOOST_MOVE_NAMESPACE::rv* >(this); }\ - operator const ::BOOST_MOVE_NAMESPACE::rv&() const \ - { return *reinterpret_cast* >(this); }\ + operator ::boost::rv&() \ + { return *static_cast< ::boost::rv* >(this); }\ + operator const ::boost::rv&() const \ + { return static_cast* >(this); }\ private:\ //More stuff... diff --git a/example/doc_clone_ptr.cpp b/example/doc_clone_ptr.cpp index e86e64b..280c94c 100644 --- a/example/doc_clone_ptr.cpp +++ b/example/doc_clone_ptr.cpp @@ -18,7 +18,7 @@ class Base public: Base(){} - // Compiler-generated copy constructor... + Base(const Base &x) {/**/} // Copy ctor Base(BOOST_RV_REF(Base) x) {/**/} // Move ctor From 6c1c4801c906f64f991433c058c8b50ff6912047 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 27 Oct 2011 19:52:22 +0000 Subject: [PATCH 04/26] Add missing html redirect for move. [SVN r75141] --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..2534bef --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + +Automatic redirection failed, please go to +../../doc/html/move.html + + From 5c77541284ff29a449106d07642faffeaf91c0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 22 Dec 2011 20:08:24 +0000 Subject: [PATCH 05/26] Introducing allocator_traits and pointer_traits changes into several libraries. [SVN r76106] --- include/boost/move/move.hpp | 113 ++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 6 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 87d63c6..2330a5c 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -23,9 +23,12 @@ #ifdef BOOST_MSVC #ifndef _CRT_SECURE_NO_DEPRECATE - #define BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE - #define _CRT_SECURE_NO_DEPRECATE - #define _SCL_SECURE_NO_WARNINGS + #define BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE + #endif + #ifndef _SCL_SECURE_NO_WARNINGS + #define BOOST_INTERPROCESS_SCL_SECURE_NO_WARNINGS + #define _SCL_SECURE_NO_WARNINGS #endif #pragma warning (push) #pragma warning(disable:4996) @@ -1080,14 +1083,112 @@ struct has_trivial_destructor_after_move : BOOST_MOVE_BOOST_NS::has_trivial_destructor {}; + + +namespace move_detail { + +// Code from Jeffrey Lee Hellrung, many thanks + +#ifndef BOOST_NO_RVALUE_REFERENCES + template< class T> struct forward_type { typedef T type; }; +#else // #ifndef BOOST_NO_RVALUE_REFERENCES + template< class T> + struct forward_type + { typedef const T &type; }; + + template< class T> + struct forward_type< boost::rv > + { typedef T type; }; +#endif // #ifndef BOOST_NO_RVALUE_REFERENCES + + + +// Code from Jeffrey Lee Hellrung, many thanks + +template< class T > struct is_rvalue_reference : BOOST_MOVE_BOOST_NS::integral_constant { }; +#ifndef BOOST_NO_RVALUE_REFERENCES + template< class T > struct is_rvalue_reference< T&& > : BOOST_MOVE_BOOST_NS::integral_constant { }; +#else // #ifndef BOOST_NO_RVALUE_REFERENCES + template< class T > struct is_rvalue_reference< boost::rv& > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; + + template< class T > struct is_rvalue_reference< const boost::rv& > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif // #ifndef BOOST_NO_RVALUE_REFERENCES + +#ifndef BOOST_NO_RVALUE_REFERENCES + template< class T > struct add_rvalue_reference { typedef T&& type; }; +#else // #ifndef BOOST_NO_RVALUE_REFERENCES + namespace detail_add_rvalue_reference + { + template< class T + , bool emulation = ::boost::has_move_emulation_enabled::value + , bool rv = ::boost::move_detail::is_rv::value > + struct add_rvalue_reference_impl { typedef T type; }; + + template< class T, bool emulation> + struct add_rvalue_reference_impl< T, emulation, true > { typedef T & type; }; + + template< class T, bool rv > + struct add_rvalue_reference_impl< T, true, rv > { typedef ::boost::rv& type; }; + } // namespace detail_add_rvalue_reference + + template< class T > + struct add_rvalue_reference + : detail_add_rvalue_reference::add_rvalue_reference_impl + { }; + + template< class T > + struct add_rvalue_reference + { typedef T & type; }; + +#endif // #ifndef BOOST_NO_RVALUE_REFERENCES + +template< class T > struct remove_rvalue_reference { typedef T type; }; + +#ifndef BOOST_NO_RVALUE_REFERENCES + template< class T > struct remove_rvalue_reference< T&& > { typedef T type; }; +#else // #ifndef BOOST_NO_RVALUE_REFERENCES + template< class T > struct remove_rvalue_reference< rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< volatile rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const volatile rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< rv& > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const rv& > { typedef T type; }; + template< class T > struct remove_rvalue_reference< volatile rv& > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const volatile rv& >{ typedef T type; }; +#endif // #ifndef BOOST_NO_RVALUE_REFERENCES + +template +typename boost::move_detail::add_rvalue_reference::type declval(); + +} +// Ideas from Boost.Move review, Jeffrey Lee Hellrung: +// +//- TypeTraits metafunctions is_lvalue_reference, add_lvalue_reference, and remove_lvalue_reference ? +// Perhaps add_reference and remove_reference can be modified so that they behave wrt emulated rvalue +// references the same as wrt real rvalue references, i.e., add_reference< rv& > -> T& rather than +// rv& (since T&& & -> T&). +// +//- Add'l TypeTraits has_[trivial_]move_{constructor,assign}...? +// +//- An as_lvalue(T& x) function, which amounts to an identity operation in C++0x, but strips emulated +// rvalue references in C++03. This may be necessary to prevent "accidental moves". + } //namespace boost { #if defined BOOST_MSVC #pragma warning (pop) #ifdef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE - #undef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE - #undef _CRT_SECURE_NO_DEPRECATE - #undef _SCL_SECURE_NO_WARNINGS + #undef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE + #undef _CRT_SECURE_NO_DEPRECATE + #endif + + #ifdef BOOST_INTERPROCESS_SCL_SECURE_NO_WARNINGS + #undef BOOST_INTERPROCESS_SCL_SECURE_NO_WARNINGS + #undef _SCL_SECURE_NO_WARNINGS #endif #endif From 424ff1db041ed76fe5f3ab8e990398ef4eb85148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 22 Dec 2011 20:15:57 +0000 Subject: [PATCH 06/26] Introducing allocator_traits and pointer_traits changes into several libraries. [SVN r76107] --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 2534bef..cb02a37 100644 --- a/index.html +++ b/index.html @@ -5,10 +5,10 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> - + -Automatic redirection failed, please go to +Automatic redirection failed, please go to ../../doc/html/move.html From 0d4ccf5556cf0f92be251db1943f33986937fcd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 23 Dec 2011 12:10:03 +0000 Subject: [PATCH 07/26] Bug #6183 [SVN r76115] --- doc/move.qbk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/move.qbk b/doc/move.qbk index 5cc8a99..c8a0e23 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -49,7 +49,7 @@ proceed to overwrite the old copy. Consider: [c++] - template swap(T& a, T& b) + template void swap(T& a, T& b) { T tmp(a); // now we have two copies of a a = b; // now we have two copies of b @@ -60,7 +60,7 @@ But, we didn't want to have any copies of a or b, we just wanted to swap them. L [c++] - template swap(T& a, T& b) + template void swap(T& a, T& b) { T tmp(::boost::move(a)); a = ::boost::move(b); From 12a8517aa50f3637db815fbe9ccb0d816e18ee93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 26 Dec 2011 11:09:52 +0000 Subject: [PATCH 08/26] Documentation fixes [SVN r76169] --- doc/move.qbk | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/move.qbk b/doc/move.qbk index c8a0e23..b542d12 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -785,4 +785,16 @@ Many thanks to all boosters that have tested, reviewed and improved the library. [endsect] +[section:release_notes Release Notes] + +[section:release_notes_boost_1_49_00 Boost 1.49 Release] + +* Fixed bugs + [@https://svn.boost.org/trac/boost/ticket/6185 #6185], + [@https://svn.boost.org/trac/boost/ticket/6183 #6183]. + +[endsect] + +[endsect] + [xinclude autodoc.xml] From 2186eacee8284d34f945097e6f868656a5d1a866 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Mon, 2 Jan 2012 12:16:49 +0000 Subject: [PATCH 09/26] Move/Thread: Added type tait so that #6141 - Compilation error when boost.thread and boost.move are used together - can be solved on the Boost.Thread side [SVN r76271] --- include/boost/move/move.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 2330a5c..4a0f158 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -283,6 +283,10 @@ : BOOST_MOVE_BOOST_NS::integral_constant {}; + template + struct has_move_emulation_enabled_aux + : has_move_emulation_enabled {}; + template struct has_nothrow_move : public BOOST_MOVE_BOOST_NS::integral_constant @@ -293,8 +297,9 @@ // move() // ////////////////////////////////////////////////////////////////////////////// + template - typename BOOST_MOVE_BOOST_NS::disable_if, T&>::type move(T& x) + typename BOOST_MOVE_BOOST_NS::disable_if, T&>::type move(T& x) { return x; } From 0f7fe1fc3f1b0aca2f6038ca99569240806e3179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 15 Jan 2012 11:09:13 +0000 Subject: [PATCH 10/26] Bug #6395: Some trivial functions aren't declared inline [SVN r76505] --- include/boost/move/move.hpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 4a0f158..284c58e 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -182,7 +182,8 @@ { return v; } }; - template T * addressof( T & v ) + template + inline T * addressof( T & v ) { return ::boost::move_detail::addressof_impl::f ( ::boost::move_detail::addr_impl_ref( v ), 0 ); @@ -299,19 +300,19 @@ ////////////////////////////////////////////////////////////////////////////// template - typename BOOST_MOVE_BOOST_NS::disable_if, T&>::type move(T& x) + inline typename BOOST_MOVE_BOOST_NS::disable_if, T&>::type move(T& x) { return x; } template - typename BOOST_MOVE_BOOST_NS::enable_if, rv&>::type move(T& x) + inline typename BOOST_MOVE_BOOST_NS::enable_if, rv&>::type move(T& x) { return *static_cast* >(BOOST_MOVE_BOOST_NS::addressof(x)); } template - typename BOOST_MOVE_BOOST_NS::enable_if, rv&>::type move(rv& x) + inline typename BOOST_MOVE_BOOST_NS::enable_if, rv&>::type move(rv& x) { return x; } @@ -356,14 +357,14 @@ ////////////////////////////////////////////////////////////////////////////// template - typename BOOST_MOVE_BOOST_NS::enable_if< ::boost::move_detail::is_rv, T &>::type + inline typename BOOST_MOVE_BOOST_NS::enable_if< ::boost::move_detail::is_rv, T &>::type forward(const typename BOOST_MOVE_MPL_NS::identity::type &x) { return const_cast(x); } template - typename BOOST_MOVE_BOOST_NS::disable_if< ::boost::move_detail::is_rv, const T &>::type + inline typename BOOST_MOVE_BOOST_NS::disable_if< ::boost::move_detail::is_rv, const T &>::type forward(const typename BOOST_MOVE_MPL_NS::identity::type &x) { return x; @@ -462,13 +463,13 @@ //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) { return t; } #else //Old move template inline - typename remove_reference::type && move(T&& t) + inline typename remove_reference::type && move(T&& t) { return static_cast::type &&>(t); } #endif //Old move @@ -498,7 +499,7 @@ //Old move approach, lvalues could bind to rvalue references template inline - T&& forward (typename BOOST_MOVE_MPL_NS::identity::type&& t) + inline T&& forward (typename BOOST_MOVE_MPL_NS::identity::type&& t) { return t; } #else //Old move @@ -735,7 +736,7 @@ struct is_move_iterator< ::boost::move_iterator > //! //! Returns: move_iterator(i). template -move_iterator make_move_iterator(const It &it) +inline move_iterator make_move_iterator(const It &it) { return move_iterator(it); } ////////////////////////////////////////////////////////////////////////////// @@ -959,7 +960,7 @@ namespace move_detail { template // F models ForwardIterator -F uninitialized_move_move_iterator(I f, I l, F r +inline F uninitialized_move_move_iterator(I f, I l, F r // ,typename BOOST_MOVE_BOOST_NS::enable_if< has_move_emulation_enabled >::type* = 0 ) { @@ -980,7 +981,7 @@ F uninitialized_move_move_iterator(I f, I l, F r, template // F models ForwardIterator -F uninitialized_copy_or_move(I f, I l, F r, +inline F uninitialized_copy_or_move(I f, I l, F r, typename BOOST_MOVE_BOOST_NS::enable_if< move_detail::is_move_iterator >::type* = 0) { return ::boost::move_detail::uninitialized_move_move_iterator(f, l, r); @@ -997,7 +998,7 @@ namespace move_detail { template // F models ForwardIterator -F move_move_iterator(I f, I l, F r +inline F move_move_iterator(I f, I l, F r // ,typename BOOST_MOVE_BOOST_NS::enable_if< has_move_emulation_enabled >::type* = 0 ) { @@ -1019,7 +1020,7 @@ F move_move_iterator(I f, I l, F r, template // F models ForwardIterator -F copy_or_move(I f, I l, F r, +inline F copy_or_move(I f, I l, F r, typename BOOST_MOVE_BOOST_NS::enable_if< move_detail::is_move_iterator >::type* = 0) { return ::boost::move_detail::move_move_iterator(f, l, r); @@ -1042,7 +1043,7 @@ F copy_or_move(I f, I l, F r, template // F models ForwardIterator -F uninitialized_copy_or_move(I f, I l, F r +inline F uninitialized_copy_or_move(I f, I l, F r /// @cond ,typename BOOST_MOVE_BOOST_NS::disable_if< move_detail::is_move_iterator >::type* = 0 /// @endcond @@ -1065,7 +1066,7 @@ F uninitialized_copy_or_move(I f, I l, F r template // F models ForwardIterator -F copy_or_move(I f, I l, F r +inline F copy_or_move(I f, I l, F r /// @cond ,typename BOOST_MOVE_BOOST_NS::disable_if< move_detail::is_move_iterator >::type* = 0 /// @endcond From 71fbccf71ea22c155f63bd99e5cf4e5888bb78bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 15 Jan 2012 12:24:52 +0000 Subject: [PATCH 11/26] Ticket #6396: Implicit instanciation of boost::rv for non-cass types generates an error [SVN r76508] --- include/boost/move/move.hpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 284c58e..4d510f4 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -225,13 +225,32 @@ namespace boost { + namespace move_detail { + template + struct is_class_or_union + { + struct twochar { char _[2]; }; + template + static char is_class_or_union_tester(void(U::*)(void)); + template + static twochar is_class_or_union_tester(...); + static const bool value = sizeof(is_class_or_union_tester(0)) == sizeof(char); + }; + struct empty{}; + } + ////////////////////////////////////////////////////////////////////////////// // // struct rv // ////////////////////////////////////////////////////////////////////////////// template - class rv : public T + class rv + : public BOOST_MOVE_MPL_NS::if_c + < ::boost::move_detail::is_class_or_union::value + , T + , ::boost::move_detail::empty + >::type { rv(); ~rv(); @@ -239,6 +258,8 @@ void operator=(rv const&); } BOOST_MOVE_ATTRIBUTE_MAY_ALIAS; + + ////////////////////////////////////////////////////////////////////////////// // // move_detail::is_rv From 740084006b615b9261e58e26205356848020a3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 15 Jan 2012 12:29:10 +0000 Subject: [PATCH 12/26] Updated changelog for 1.49 [SVN r76510] --- doc/move.qbk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/move.qbk b/doc/move.qbk index b542d12..b029ae0 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -790,8 +790,10 @@ Many thanks to all boosters that have tested, reviewed and improved the library. [section:release_notes_boost_1_49_00 Boost 1.49 Release] * Fixed bugs + [@https://svn.boost.org/trac/boost/ticket/6183 #6183], [@https://svn.boost.org/trac/boost/ticket/6185 #6185], - [@https://svn.boost.org/trac/boost/ticket/6183 #6183]. + [@https://svn.boost.org/trac/boost/ticket/6395 #6395], + [@https://svn.boost.org/trac/boost/ticket/6396 #6396], [endsect] From 0c91eec7d4b525500f587a198876290a0f71b69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 16 Jan 2012 21:24:21 +0000 Subject: [PATCH 13/26] Fixed double inline [SVN r76546] --- include/boost/move/move.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 4d510f4..1f89d03 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -477,19 +477,19 @@ //! This function provides a way to convert a reference into a rvalue reference //! in compilers with rvalue references. For other compilers converts T & into //! ::boost::rv & so that move emulation is activated. - template inline + template rvalue_reference move (input_reference); #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) //Old move approach, lvalues could bind to rvalue references - template inline + template inline typename remove_reference::type && move(T&& t) { return t; } #else //Old move - template inline + template inline typename remove_reference::type && move(T&& t) { return static_cast::type &&>(t); } @@ -514,12 +514,12 @@ //! ::boost::rev & //! //! * Else, input_reference is equal to output_reference is equal to input_reference. - template inline output_reference forward(input_reference); + template output_reference forward(input_reference); #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) //Old move approach, lvalues could bind to rvalue references - template inline + template inline T&& forward (typename BOOST_MOVE_MPL_NS::identity::type&& t) { return t; } From 0e41df8f0548b78de64340d8b80680f8258b047d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 18 Jan 2012 20:48:49 +0000 Subject: [PATCH 14/26] Added fixed bugs to changeset in container/interprocess/intrusive/move [SVN r76578] --- doc/move.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/move.qbk b/doc/move.qbk index b029ae0..bd90baa 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -790,6 +790,7 @@ Many thanks to all boosters that have tested, reviewed and improved the library. [section:release_notes_boost_1_49_00 Boost 1.49 Release] * Fixed bugs + [@https://svn.boost.org/trac/boost/ticket/6417 #6417], [@https://svn.boost.org/trac/boost/ticket/6183 #6183], [@https://svn.boost.org/trac/boost/ticket/6185 #6185], [@https://svn.boost.org/trac/boost/ticket/6395 #6395], From d53266613b8454d329bc00cb8c21c2b246c47634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 11 Feb 2012 18:30:05 +0000 Subject: [PATCH 15/26] Ticket #6519: Image files corrupted due to some cr lf conversion. [SVN r76984] --- doc/html/images/blank.png | Bin 392 -> 374 bytes doc/html/images/caution.png | Bin 1253 -> 1250 bytes doc/html/images/draft.png | Bin 17539 -> 17454 bytes doc/html/images/home.png | Bin 361 -> 358 bytes doc/html/images/important.png | Bin 726 -> 722 bytes doc/html/images/next.png | Bin 342 -> 336 bytes doc/html/images/note.png | Bin 495 -> 490 bytes doc/html/images/prev.png | Bin 338 -> 334 bytes doc/html/images/tip.png | Bin 456 -> 449 bytes doc/html/images/toc-blank.png | Bin 321 -> 318 bytes doc/html/images/toc-minus.png | Bin 262 -> 259 bytes doc/html/images/toc-plus.png | Bin 267 -> 264 bytes doc/html/images/warning.png | Bin 1244 -> 1241 bytes 13 files changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/html/images/blank.png b/doc/html/images/blank.png index c387d424b21d641808bf44ca19f001bb7fde5d78..764bf4f0c3bb4a09960b04b6fa9c9024bca703bc 100644 GIT binary patch literal 374 zcmeAS@N?(olHy`uVBq!ia0y~yU}ykg4kiW$2A`O3a~K#HSkfJR9T^xl_H+M9WMyDr z)b(_645^s&_M)R8g96V1g9H1Y`?|@Qa8+HmHda4(nQ?zM!!?FAj1kNm*b;aTNHv%; cj9>w=gf!;AOne?`3=9kmp00i_>zopr0BeCVqjos0AUU$1_lP7m~V3!7#LX69eo`c7&i8E|4C$J zU|`hsba4!+nDh3cqacF<&jEu2`=9%|$(e9fUAHz?KX;jNe>TH4hBb^4%p2Gec)1Qp hHJCDtioilcEFq2gFB6|f8Uq6ZgQu&X%Q~loCIIhfY*qjO diff --git a/doc/html/images/caution.png b/doc/html/images/caution.png index b056bccddb7f56b998b401bde72c561f64e65b4b..5b7809ca4a9c8d778087522e5ce04b6e90099595 100644 GIT binary patch delta 26 hcmaFL`G}LJGr-TCmrII^fq{W{Bi{<<&D)vv7y)6f2BH7} delta 30 lcmaFF`IM8dGr-TCmy1h^i-CcGmun->3T8&G&0CoD7y)!h2EG6Q diff --git a/doc/html/images/draft.png b/doc/html/images/draft.png index c99e091f224c503389c27d468ac46a7cee87135c..0084708c9b8287c51efa6b40b8d492854191455e 100644 GIT binary patch delta 474 zcmZqfWL($5$kQ3%=g!L|#l^tDz&nv|=EM~f1sQG}NH+blRr!gDA}<3+t}pLoU&b4g z)tIhM{=@WzpF#6O`L?P2*P_my-o>iOJDHK?=H%NfUX#^WRW^IG3NcQOW9!}ghRvIC zvIWQL$xk>exE^SDWUScx)I^bYvIeKgj)#UA5 zJ0=%!UlcoF?ax`e!p~4%HGkf7*Fcs3Z11ELc_&Bm%%A*|$9A(hFB{`zJ3g_=p?u1d zEBW#!zu-%q?8iTQ^DBNiMyZ_lvs=QvBD1$%a}9h_85b%VD9iKs-VGT=-pMM0ij&<0 zA52yk3Y=UiZy~zs9&9YN@MxvB28At%@taFjGNoFEtobR&|ShbIn^Lw z^EQK8#>pl|%QoLOa$#JoV8Xmv(Y%#W{K115yGb4|7?_@vTrWK)v9^@w`4oe9yp#7^ joY>r9>C3qJn$;Yp&Be9{nI@Y$OrCtwVaMhsM@D7iO%Qg8s^G!ys$ro6>7`Y}( zv8pg~ZMI_-Vr1l+9KhDg$hG+{n>UD~!Lgc=Yw~3d3m&cq8Xg%d_C5t!GFg<i6C>AT zMsZn2uFZ1d1|XOCNz7p6n*2=SKO@)Vr;>*lxh5}{0vYvI>Mn=5sffXtUQ2w>#eoNG`EGXIs~ zGDfb=6O3FK8Mzi;F=l4u+I+>Vl~I!G!GjpPNggj4n4XkeFFhu)wv^}j6oYrXT$2kd nPB3z9wy^XCS7<2jSZ9ObP$vZre4>tlwJ9yLkhn5+eW*#0{AM diff --git a/doc/html/images/next.png b/doc/html/images/next.png index f9f1081f4f2ddc3a1890daf50cbd944c718afd9b..59800b4e87f60c0e3383ede2b384b9be0f5ffe8d 100644 GIT binary patch delta 73 zcmcb{bb*PdGr-TCmrII^fq{W{BHu#;mZ>)#l9-t%+}PK^d+g590~2^trx_V+aGYt) fW#Kgko@Q`=1GNUm7uB{sR delta 53 zcmcb>bd8CxGr-TCmy1h^i-CcGmun)=Ls2f4sW%;xn3*Ts*w?_zb?na30~2_;CjOUW KC5~qpvC0S1hJ diff --git a/doc/html/images/prev.png b/doc/html/images/prev.png index 22b8ac2c1d7c4d2bfa100c3a29b5b0593f43a71f..d88a40f923e3c554125f01cd366707c60cfcad04 100644 GIT binary patch delta 33 ocmcb_bdHI=Gr-TCmrH6RCkG=B7t>4!N4Bd03I+)bljRwW0h0Cz0RR91 delta 37 scmX@dbcu^keJMpq6Bk#mNM**7J7!3db diff --git a/doc/html/images/toc-blank.png b/doc/html/images/toc-blank.png index 75b24d6fc4aafdebbc3b9adfe816fbbc546ea3e9..6ffad17a0c7a78deaae58716e8071cc40cb0b8e0 100644 GIT binary patch delta 25 gcmX@ew2z6WGr-TCmrII^fq{W{BcCASWCcb=08JnS>;M1& delta 29 kcmdnTbdZU!Gr-TCmy1h^i-CcGmun-BAR{B!WLZW<09_OX2mk;8 diff --git a/doc/html/images/toc-minus.png b/doc/html/images/toc-minus.png index 7a8a2740efa22c214ec701878b02c970eec0e56a..abbb020c8e2d6705ebc2f0fc17deed30f2977a46 100644 GIT binary patch delta 23 ecmZo;YG&f;4DfU3<&xrJU|`^#$aihxQ$+wh?giWc delta 57 zcmZo>YGdN-4DfU3<>Hd!Vqjq4<(kNIO^K_-HKHUSF+G*R(6qu*+d$jEyzIjc1_lNO MPgg&ebxsLQ0DRI8n*aa+ diff --git a/doc/html/images/toc-plus.png b/doc/html/images/toc-plus.png index 29fada25c1d6c039ab4ad5682d3a11bb80b56781..941312ce0dab168e0efcc5b572e387259880e541 100644 GIT binary patch delta 23 ecmeBX>R{sO4DfU3<&xrJU|`^#$aj0Sp5W4DfU3<>Hd!Vqjq4<(kNIn~`hcb4377P6iAB diff --git a/doc/html/images/warning.png b/doc/html/images/warning.png index 74fc1ba2b4a7693f381d09607b6c2aaca3c043f7..1c33db8f34a8b42b373179b46a2d8d8a10e061a9 100644 GIT binary patch delta 21 ccmcb^d6Sd9Gr-TCmrH6R=MLu0hnS@p0Zo<$b^rhX delta 25 gcmcb~d54p;Gr-TCmzPV5cO&}_W=7u4` Date: Thu, 22 Mar 2012 18:51:38 +0000 Subject: [PATCH 16/26] Added BOOST_RV_REF_BEG and BOOST_RV_REF_END macros to ease declaring rvalues of template classes [SVN r77483] --- include/boost/move/move.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 1f89d03..276a3db 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -350,6 +350,15 @@ ::boost::rv< TYPE >& \ // + #define BOOST_RV_REF_BEG\ + ::boost::rv< \ + // + + #define BOOST_RV_REF_END\ + >& \ + // + + #define BOOST_FWD_REF(TYPE)\ const TYPE & \ @@ -569,6 +578,25 @@ TYPE && \ // + //!This macro is used to achieve portable syntax in move + //!constructors and assignments for template classes marked as + //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. + //!As macros have problem with comma-separatd template arguments, + //!the template argument must be preceded with BOOST_RV_REF_START + //!and ended with BOOST_RV_REF_END + #define BOOST_RV_REF_BEG\ + \ + // + + //!This macro is used to achieve portable syntax in move + //!constructors and assignments for template classes marked as + //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. + //!As macros have problem with comma-separatd template arguments, + //!the template argument must be preceded with BOOST_RV_REF_START + //!and ended with BOOST_RV_REF_END + #define BOOST_RV_REF_END\ + && \ + //!This macro is used to achieve portable syntax in copy //!assignment for classes marked as BOOST_COPYABLE_AND_MOVABLE. #define BOOST_COPY_ASSIGN_REF(TYPE)\ From 026c48d377c71864f3f9670ffed46dc1435dcd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 10 Apr 2012 18:48:02 +0000 Subject: [PATCH 17/26] Added BOOST_COPY_ASSIGN_REF_BEG/END macro to ease portable template class usage [SVN r77890] --- include/boost/move/move.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 276a3db..e43623d 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -372,6 +372,14 @@ const ::boost::rv< TYPE >& \ // + #define BOOST_COPY_ASSIGN_REF_BEG \ + const ::boost::rv< \ + // + + #define BOOST_COPY_ASSIGN_REF_END \ + >& \ + // + #define BOOST_MOVE_COPY_ASSIGN_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ const ::boost::rv< TYPE >& \ // From a17a0b882b7fcab71d4503772c747d5c5740e7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 22 Apr 2012 22:54:18 +0000 Subject: [PATCH 18/26] Fixed clang warnings and errors [SVN r78149] --- example/doc_clone_ptr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/doc_clone_ptr.cpp b/example/doc_clone_ptr.cpp index 280c94c..56c0816 100644 --- a/example/doc_clone_ptr.cpp +++ b/example/doc_clone_ptr.cpp @@ -30,6 +30,8 @@ class Base virtual Base *clone() const { return new Base(*this); } + + virtual ~Base(){} }; class Member From 8a4cef0b82eb6920a5375c460029f077689966e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 20 May 2012 10:08:33 +0000 Subject: [PATCH 19/26] Trailing whitespaces [SVN r78520] --- include/boost/move/move.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index e43623d..172ef30 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -217,9 +217,9 @@ #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) //Move emulation rv breaks standard aliasing rules so add workarounds for some compilers - #ifdef __GNUC__ - #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__)) - #else + #ifdef __GNUC__ + #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__)) + #else #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS #endif @@ -306,10 +306,10 @@ {}; template - struct has_move_emulation_enabled_aux + struct has_move_emulation_enabled_aux : has_move_emulation_enabled {}; - - template + + template struct has_nothrow_move : public BOOST_MOVE_BOOST_NS::integral_constant {}; @@ -319,7 +319,7 @@ // move() // ////////////////////////////////////////////////////////////////////////////// - + template inline typename BOOST_MOVE_BOOST_NS::disable_if, T&>::type move(T& x) { @@ -460,7 +460,7 @@ //! By default this traits returns false. Classes with non-throwing move constructor //! and assignment should specialize this trait to obtain some performance improvements. - template + template struct has_nothrow_move : public BOOST_MOVE_MPL_NS::integral_constant {}; @@ -494,7 +494,7 @@ //! This function provides a way to convert a reference into a rvalue reference //! in compilers with rvalue references. For other compilers converts T & into //! ::boost::rv & so that move emulation is activated. - template + template rvalue_reference move (input_reference); #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) @@ -508,7 +508,7 @@ template inline typename remove_reference::type && move(T&& t) - { return static_cast::type &&>(t); } + { return static_cast::type &&>(t); } #endif //Old move @@ -1222,7 +1222,7 @@ template< class T > struct remove_rvalue_reference { typedef T type; }; template< class T > struct remove_rvalue_reference< const rv& > { typedef T type; }; template< class T > struct remove_rvalue_reference< volatile rv& > { typedef T type; }; template< class T > struct remove_rvalue_reference< const volatile rv& >{ typedef T type; }; -#endif // #ifndef BOOST_NO_RVALUE_REFERENCES +#endif // #ifndef BOOST_NO_RVALUE_REFERENCES template typename boost::move_detail::add_rvalue_reference::type declval(); @@ -1230,7 +1230,7 @@ typename boost::move_detail::add_rvalue_reference::type declval(); } // Ideas from Boost.Move review, Jeffrey Lee Hellrung: // -//- TypeTraits metafunctions is_lvalue_reference, add_lvalue_reference, and remove_lvalue_reference ? +//- TypeTraits metafunctions is_lvalue_reference, add_lvalue_reference, and remove_lvalue_reference ? // Perhaps add_reference and remove_reference can be modified so that they behave wrt emulated rvalue // references the same as wrt real rvalue references, i.e., add_reference< rv& > -> T& rather than // rv& (since T&& & -> T&). @@ -1238,7 +1238,7 @@ typename boost::move_detail::add_rvalue_reference::type declval(); //- Add'l TypeTraits has_[trivial_]move_{constructor,assign}...? // //- An as_lvalue(T& x) function, which amounts to an identity operation in C++0x, but strips emulated -// rvalue references in C++03. This may be necessary to prevent "accidental moves". +// rvalue references in C++03. This may be necessary to prevent "accidental moves". } //namespace boost { From 29b97a751345cb0b0b0e10b6a7828d41f5df79dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 11 Jul 2012 17:59:25 +0000 Subject: [PATCH 20/26] Ticket #7095: warning: unrecognized __attribute__((__may_alias__)) [SVN r79424] --- include/boost/move/move.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 172ef30..d6b1039 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -217,7 +217,7 @@ #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) //Move emulation rv breaks standard aliasing rules so add workarounds for some compilers - #ifdef __GNUC__ + #if defined(__GNUC__) && (__GNUC__ >= 4) #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__)) #else #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS From 011e729ca6cbe0cfbfb7e5efd4b546c0c8d3b458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 11 Jul 2012 22:09:37 +0000 Subject: [PATCH 21/26] Updated changeset [SVN r79430] --- doc/move.qbk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/move.qbk b/doc/move.qbk index bd90baa..d28b205 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -787,6 +787,13 @@ Many thanks to all boosters that have tested, reviewed and improved the library. [section:release_notes Release Notes] +[section:release_notes_boost_1_51_00 Boost 1.51 Release] + +* Fixed bug + [@https://svn.boost.org/trac/boost/ticket/7095 #7095]. + +[endsect] + [section:release_notes_boost_1_49_00 Boost 1.49 Release] * Fixed bugs From 34009be49927d8d3ffe957104d19b3fac731f690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 11 Jul 2012 22:32:47 +0000 Subject: [PATCH 22/26] Ticket #7031: (back_|front_)move_insert_iterator::op= cannot take rvalue [SVN r79431] --- include/boost/move/move.hpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index d6b1039..6029d6d 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -812,13 +812,18 @@ class back_move_insert_iterator C* container_m; public: - typedef C container_type; + typedef C container_type; + typedef typename C::value_type value_type; + typedef typename C::reference reference; explicit back_move_insert_iterator(C& x) : container_m(&x) { } - back_move_insert_iterator& operator=(typename C::reference x) + back_move_insert_iterator& operator=(reference x) { container_m->push_back(boost::move(x)); return *this; } + back_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) + { reference rx = x; return this->operator=(rx); } + back_move_insert_iterator& operator*() { return *this; } back_move_insert_iterator& operator++() { return *this; } back_move_insert_iterator& operator++(int) { return *this; } @@ -847,13 +852,18 @@ class front_move_insert_iterator C* container_m; public: - typedef C container_type; + typedef C container_type; + typedef typename C::value_type value_type; + typedef typename C::reference reference; explicit front_move_insert_iterator(C& x) : container_m(&x) { } - front_move_insert_iterator& operator=(typename C::reference x) + front_move_insert_iterator& operator=(reference x) { container_m->push_front(boost::move(x)); return *this; } + front_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) + { reference rx = x; return this->operator=(rx); } + front_move_insert_iterator& operator*() { return *this; } front_move_insert_iterator& operator++() { return *this; } front_move_insert_iterator& operator++(int) { return *this; } @@ -880,19 +890,24 @@ class move_insert_iterator typename C::iterator pos_; public: - typedef C container_type; + typedef C container_type; + typedef typename C::value_type value_type; + typedef typename C::reference reference; explicit move_insert_iterator(C& x, typename C::iterator pos) : container_m(&x), pos_(pos) {} - move_insert_iterator& operator=(typename C::reference x) + move_insert_iterator& operator=(reference x) { pos_ = container_m->insert(pos_, ::boost::move(x)); ++pos_; return *this; } + move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) + { reference rx = x; return this->operator=(rx); } + move_insert_iterator& operator*() { return *this; } move_insert_iterator& operator++() { return *this; } move_insert_iterator& operator++(int) { return *this; } From bdd17fdc07789dc586d505af0cc49d5cd5cc182e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 11 Jul 2012 22:35:00 +0000 Subject: [PATCH 23/26] Ticket #7031: (back_|front_)move_insert_iterator::op= cannot take rvalue [SVN r79432] --- doc/move.qbk | 5 ++-- test/back_move_inserter.cpp | 49 +++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/doc/move.qbk b/doc/move.qbk index d28b205..7224176 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -789,8 +789,9 @@ Many thanks to all boosters that have tested, reviewed and improved the library. [section:release_notes_boost_1_51_00 Boost 1.51 Release] -* Fixed bug - [@https://svn.boost.org/trac/boost/ticket/7095 #7095]. +* Fixed bugs + [@https://svn.boost.org/trac/boost/ticket/7095 #7095], + [@https://svn.boost.org/trac/boost/ticket/7031 #7031]. [endsect] diff --git a/test/back_move_inserter.cpp b/test/back_move_inserter.cpp index ca4720b..1505125 100644 --- a/test/back_move_inserter.cpp +++ b/test/back_move_inserter.cpp @@ -17,29 +17,42 @@ template int move_test() { - //Default construct 10 movable objects - Container v(10); + bool use_move_iterator = false; + bool done = false; + while(!done){ + //Default construct 10 movable objects + Container v(10); - //Test default constructed value - if(v.begin()->moved()){ - return 1; - } + //Test default constructed value + if(v.begin()->moved()){ + return 1; + } - //Move values - Container v2; - std::copy(v.begin(), v.end(), boost::back_move_inserter(v2)); + //Move values + Container v2; + if(use_move_iterator){ + ::boost::copy_or_move( boost::make_move_iterator(v.begin()) + , boost::make_move_iterator(v.end()) + , boost::back_move_inserter(v2)); + } + else{ + std::copy(v.begin(), v.end(), boost::back_move_inserter(v2)); + } - //Test values have been moved - if(!v.begin()->moved()){ - return 1; - } + //Test values have been moved + if(!v.begin()->moved()){ + return 1; + } - if(v2.size() != 10){ - return 1; - } + if(v2.size() != 10){ + return 1; + } - if(v2.begin()->moved()){ - return 1; + if(v2.begin()->moved()){ + return 1; + } + done = use_move_iterator; + use_move_iterator = true; } return 0; } From b16287f72aa2c4fb2c6c9ebc102c8842b4c4b657 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Fri, 23 Nov 2012 14:57:04 +0000 Subject: [PATCH 24/26] Remove usage of deprecated macros [SVN r81492] --- include/boost/move/move.hpp | 38 ++++++++++++++--------------- include/boost/move/move_helpers.hpp | 10 ++++---- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index 6029d6d..b0f086c 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -195,7 +195,7 @@ #endif //BOOST_MOVE_AVOID_BOOST_DEPENDENCIES //Compiler workaround detection -#if !defined(BOOST_NO_RVALUE_REFERENCES) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) && !defined(__clang__) //Pre-standard rvalue binding rules @@ -214,7 +214,7 @@ #endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) -#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) //Move emulation rv breaks standard aliasing rules so add workarounds for some compilers #if defined(__GNUC__) && (__GNUC__ >= 4) @@ -454,7 +454,7 @@ } //namespace boost -#else //BOOST_NO_RVALUE_REFERENCES +#else //BOOST_NO_CXX11_RVALUE_REFERENCES namespace boost{ @@ -645,7 +645,7 @@ #endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) -#endif //BOOST_NO_RVALUE_REFERENCES +#endif //BOOST_NO_CXX11_RVALUE_REFERENCES namespace boost { @@ -666,7 +666,7 @@ class move_iterator public: typedef It iterator_type; typedef typename std::iterator_traits::value_type value_type; - #if !defined(BOOST_NO_RVALUE_REFERENCES) || defined(BOOST_MOVE_DOXYGEN_INVOKED) + #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_DOXYGEN_INVOKED) typedef value_type && reference; #else typedef typename BOOST_MOVE_MPL_NS::if_ @@ -695,7 +695,7 @@ class move_iterator reference operator*() const { - #if defined(BOOST_NO_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) + #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) return *m_it; #else return ::boost::move(*m_it); @@ -731,7 +731,7 @@ class move_iterator reference operator[](difference_type n) const { - #if defined(BOOST_NO_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) + #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) return m_it[n]; #else return ::boost::move(m_it[n]); @@ -1167,9 +1167,9 @@ namespace move_detail { // Code from Jeffrey Lee Hellrung, many thanks -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T> struct forward_type { typedef T type; }; -#else // #ifndef BOOST_NO_RVALUE_REFERENCES +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T> struct forward_type { typedef const T &type; }; @@ -1177,16 +1177,16 @@ namespace move_detail { template< class T> struct forward_type< boost::rv > { typedef T type; }; -#endif // #ifndef BOOST_NO_RVALUE_REFERENCES +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES // Code from Jeffrey Lee Hellrung, many thanks template< class T > struct is_rvalue_reference : BOOST_MOVE_BOOST_NS::integral_constant { }; -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T > struct is_rvalue_reference< T&& > : BOOST_MOVE_BOOST_NS::integral_constant { }; -#else // #ifndef BOOST_NO_RVALUE_REFERENCES +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T > struct is_rvalue_reference< boost::rv& > : BOOST_MOVE_BOOST_NS::integral_constant {}; @@ -1194,11 +1194,11 @@ template< class T > struct is_rvalue_reference : BOOST_MOVE_BOOST_NS::integral_c template< class T > struct is_rvalue_reference< const boost::rv& > : BOOST_MOVE_BOOST_NS::integral_constant {}; -#endif // #ifndef BOOST_NO_RVALUE_REFERENCES +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T > struct add_rvalue_reference { typedef T&& type; }; -#else // #ifndef BOOST_NO_RVALUE_REFERENCES +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES namespace detail_add_rvalue_reference { template< class T @@ -1222,13 +1222,13 @@ template< class T > struct is_rvalue_reference : BOOST_MOVE_BOOST_NS::integral_c struct add_rvalue_reference { typedef T & type; }; -#endif // #ifndef BOOST_NO_RVALUE_REFERENCES +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T > struct remove_rvalue_reference { typedef T type; }; -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T > struct remove_rvalue_reference< T&& > { typedef T type; }; -#else // #ifndef BOOST_NO_RVALUE_REFERENCES +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template< class T > struct remove_rvalue_reference< rv > { typedef T type; }; template< class T > struct remove_rvalue_reference< const rv > { typedef T type; }; template< class T > struct remove_rvalue_reference< volatile rv > { typedef T type; }; @@ -1237,7 +1237,7 @@ template< class T > struct remove_rvalue_reference { typedef T type; }; template< class T > struct remove_rvalue_reference< const rv& > { typedef T type; }; template< class T > struct remove_rvalue_reference< volatile rv& > { typedef T type; }; template< class T > struct remove_rvalue_reference< const volatile rv& >{ typedef T type; }; -#endif // #ifndef BOOST_NO_RVALUE_REFERENCES +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template typename boost::move_detail::add_rvalue_reference::type declval(); diff --git a/include/boost/move/move_helpers.hpp b/include/boost/move/move_helpers.hpp index eaf51d6..8f78c53 100644 --- a/include/boost/move/move_helpers.hpp +++ b/include/boost/move/move_helpers.hpp @@ -15,16 +15,16 @@ #include #include -#if defined(BOOST_NO_RVALUE_REFERENCES) || (defined(_MSC_VER) && (_MSC_VER == 1600)) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || (defined(_MSC_VER) && (_MSC_VER == 1600)) #include #include #endif -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #include #endif -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) struct not_a_type; #define BOOST_MOVE_CATCH_CONST(U) \ typename ::boost::mpl::if_< ::boost::is_class, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type @@ -37,7 +37,7 @@ struct not_a_type; #define BOOST_MOVE_CATCH_FWD(U) U && #endif -#ifdef BOOST_NO_RVALUE_REFERENCES +#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ @@ -104,7 +104,7 @@ struct not_a_type; #endif -#ifdef BOOST_NO_RVALUE_REFERENCES +#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1)\ RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ From b4349e3fa7454ccfc3e0ecf950f262dca21f177e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 24 Nov 2012 20:48:31 +0000 Subject: [PATCH 25/26] * Better header segregation (bug [@https://svn.boost.org/trac/boost/ticket/6524 #6524]). * Small documentation fixes * Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros. [SVN r81513] --- include/boost/move/algorithm.hpp | 258 ++++ include/boost/move/core.hpp | 309 ++++ include/boost/move/detail/config_begin.hpp | 23 + include/boost/move/detail/config_end.hpp | 20 + include/boost/move/detail/meta_utils.hpp | 158 ++ .../boost/move/{ => detail}/move_helpers.hpp | 6 +- include/boost/move/iterator.hpp | 298 ++++ include/boost/move/move.hpp | 1266 +---------------- include/boost/move/traits.hpp | 142 ++ include/boost/move/utility.hpp | 194 +++ 10 files changed, 1416 insertions(+), 1258 deletions(-) create mode 100644 include/boost/move/algorithm.hpp create mode 100644 include/boost/move/core.hpp create mode 100644 include/boost/move/detail/config_begin.hpp create mode 100644 include/boost/move/detail/config_end.hpp create mode 100644 include/boost/move/detail/meta_utils.hpp rename include/boost/move/{ => detail}/move_helpers.hpp (97%) create mode 100644 include/boost/move/iterator.hpp create mode 100644 include/boost/move/traits.hpp create mode 100644 include/boost/move/utility.hpp diff --git a/include/boost/move/algorithm.hpp b/include/boost/move/algorithm.hpp new file mode 100644 index 0000000..bc6639f --- /dev/null +++ b/include/boost/move/algorithm.hpp @@ -0,0 +1,258 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +//! \file + +#ifndef BOOST_MOVE_ALGORITHM_HPP +#define BOOST_MOVE_ALGORITHM_HPP + +#include + +#include +#include +#include + +#include //copy, copy_backward +#include //uninitialized_copy + +namespace boost { + +////////////////////////////////////////////////////////////////////////////// +// +// move +// +////////////////////////////////////////////////////////////////////////////// + +#if !defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) + + //! Effects: Moves elements in the range [first,last) into the range [result,result + (last - + //! first)) starting from first and proceeding to last. For each non-negative integer n < (last-first), + //! performs *(result + n) = ::boost::move (*(first + n)). + //! + //! Effects: result + (last - first). + //! + //! Requires: result shall not be in the range [first,last). + //! + //! Complexity: Exactly last - first move assignments. + template // O models OutputIterator + O move(I f, I l, O result) + { + while (f != l) { + *result = ::boost::move(*f); + ++f; ++result; + } + return result; + } + + ////////////////////////////////////////////////////////////////////////////// + // + // move_backward + // + ////////////////////////////////////////////////////////////////////////////// + + //! Effects: Moves elements in the range [first,last) into the range + //! [result - (last-first),result) starting from last - 1 and proceeding to + //! first. For each positive integer n <= (last - first), + //! performs *(result - n) = ::boost::move(*(last - n)). + //! + //! Requires: result shall not be in the range [first,last). + //! + //! Returns: result - (last - first). + //! + //! Complexity: Exactly last - first assignments. + template // O models BidirectionalIterator + O move_backward(I f, I l, O result) + { + while (f != l) { + --l; --result; + *result = ::boost::move(*l); + } + return result; + } + +#endif //!defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) + +////////////////////////////////////////////////////////////////////////////// +// +// uninitialized_move +// +////////////////////////////////////////////////////////////////////////////// + +//! Effects: +//! \code +//! for (; first != last; ++result, ++first) +//! new (static_cast(&*result)) +//! typename iterator_traits::value_type(boost::move(*first)); +//! \endcode +//! +//! Returns: result +template + // F models ForwardIterator +F uninitialized_move(I f, I l, F r + /// @cond +// ,typename ::boost::move_detail::enable_if::value_type> >::type* = 0 + /// @endcond + ) +{ + typedef typename std::iterator_traits::value_type input_value_type; + while (f != l) { + ::new(static_cast(&*r)) input_value_type(boost::move(*f)); + ++f; ++r; + } + return r; +} + +/// @cond +/* +template + // F models ForwardIterator +F uninitialized_move(I f, I l, F r, + typename ::boost::move_detail::disable_if::value_type> >::type* = 0) +{ + return std::uninitialized_copy(f, l, r); +} +*/ + +////////////////////////////////////////////////////////////////////////////// +// +// uninitialized_copy_or_move +// +////////////////////////////////////////////////////////////////////////////// + +namespace move_detail { + +template + // F models ForwardIterator +inline F uninitialized_move_move_iterator(I f, I l, F r +// ,typename ::boost::move_detail::enable_if< has_move_emulation_enabled >::type* = 0 +) +{ + return ::boost::uninitialized_move(f, l, r); +} +/* +template + // F models ForwardIterator +F uninitialized_move_move_iterator(I f, I l, F r, + typename ::boost::move_detail::disable_if< has_move_emulation_enabled >::type* = 0) +{ + return std::uninitialized_copy(f.base(), l.base(), r); +} +*/ +} //namespace move_detail { + +template + // F models ForwardIterator +inline F uninitialized_copy_or_move(I f, I l, F r, + typename ::boost::move_detail::enable_if< move_detail::is_move_iterator >::type* = 0) +{ + return ::boost::move_detail::uninitialized_move_move_iterator(f, l, r); +} + +////////////////////////////////////////////////////////////////////////////// +// +// copy_or_move +// +////////////////////////////////////////////////////////////////////////////// + +namespace move_detail { + +template + // F models ForwardIterator +inline F move_move_iterator(I f, I l, F r +// ,typename ::boost::move_detail::enable_if< has_move_emulation_enabled >::type* = 0 +) +{ + return ::boost::move(f, l, r); +} +/* +template + // F models ForwardIterator +F move_move_iterator(I f, I l, F r, + typename ::boost::move_detail::disable_if< has_move_emulation_enabled >::type* = 0) +{ + return std::copy(f.base(), l.base(), r); +} +*/ + +} //namespace move_detail { + +template + // F models ForwardIterator +inline F copy_or_move(I f, I l, F r, + typename ::boost::move_detail::enable_if< move_detail::is_move_iterator >::type* = 0) +{ + return ::boost::move_detail::move_move_iterator(f, l, r); +} + +/// @endcond + +//! Effects: +//! \code +//! for (; first != last; ++result, ++first) +//! new (static_cast(&*result)) +//! typename iterator_traits::value_type(*first); +//! \endcode +//! +//! Returns: result +//! +//! Note: This function is provided because +//! std::uninitialized_copy from some STL implementations +//! is not compatible with move_iterator +template + // F models ForwardIterator +inline F uninitialized_copy_or_move(I f, I l, F r + /// @cond + ,typename ::boost::move_detail::disable_if< move_detail::is_move_iterator >::type* = 0 + /// @endcond + ) +{ + return std::uninitialized_copy(f, l, r); +} + +//! Effects: +//! \code +//! for (; first != last; ++result, ++first) +//! *result = *first; +//! \endcode +//! +//! Returns: result +//! +//! Note: This function is provided because +//! std::uninitialized_copy from some STL implementations +//! is not compatible with move_iterator +template + // F models ForwardIterator +inline F copy_or_move(I f, I l, F r + /// @cond + ,typename ::boost::move_detail::disable_if< move_detail::is_move_iterator >::type* = 0 + /// @endcond + ) +{ + return std::copy(f, l, r); +} + +} //namespace boost { + +#include + +#endif //#ifndef BOOST_MOVE_MOVE_HPP diff --git a/include/boost/move/core.hpp b/include/boost/move/core.hpp new file mode 100644 index 0000000..2a11bad --- /dev/null +++ b/include/boost/move/core.hpp @@ -0,0 +1,309 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +//! \file core.hpp +//! This header implements macros to define movable classes and +//! move-aware functions + +#ifndef BOOST_MOVE_CORE_HPP +#define BOOST_MOVE_CORE_HPP + +#include + +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) + + #include + + //Move emulation rv breaks standard aliasing rules so add workarounds for some compilers + #if defined(__GNUC__) && (__GNUC__ >= 4) + #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__)) + #else + #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS + #endif + + namespace boost { + + ////////////////////////////////////////////////////////////////////////////// + // + // struct rv + // + ////////////////////////////////////////////////////////////////////////////// + template + class rv + : public ::boost::move_detail::if_c + < ::boost::move_detail::is_class_or_union::value + , T + , ::boost::move_detail::empty + >::type + { + rv(); + ~rv(); + rv(rv const&); + void operator=(rv const&); + } BOOST_MOVE_ATTRIBUTE_MAY_ALIAS; + + + ////////////////////////////////////////////////////////////////////////////// + // + // move_detail::is_rv + // + ////////////////////////////////////////////////////////////////////////////// + + namespace move_detail { + + template + struct is_rv + : ::boost::move_detail::integral_constant + {}; + + template + struct is_rv< rv > + : ::boost::move_detail::integral_constant + {}; + + template + struct is_rv< const rv > + : ::boost::move_detail::integral_constant + {}; + + } //namespace move_detail { + + ////////////////////////////////////////////////////////////////////////////// + // + // has_move_emulation_enabled + // + ////////////////////////////////////////////////////////////////////////////// + template + struct has_move_emulation_enabled + : ::boost::move_detail::is_convertible< T, ::boost::rv& > + {}; + + template + struct has_move_emulation_enabled + : ::boost::move_detail::integral_constant + {}; + + template + struct has_move_emulation_enabled< ::boost::rv > + : ::boost::move_detail::integral_constant + {}; + + } //namespace boost { + + #define BOOST_RV_REF(TYPE)\ + ::boost::rv< TYPE >& \ + // + + #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ + ::boost::rv< TYPE >& \ + // + + #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ + ::boost::rv< TYPE >& \ + // + + #define BOOST_RV_REF_BEG\ + ::boost::rv< \ + // + + #define BOOST_RV_REF_END\ + >& \ + // + + #define BOOST_FWD_REF(TYPE)\ + const TYPE & \ + // + + #define BOOST_CATCH_CONST_RLVALUE(TYPE)\ + const ::boost::rv< TYPE >& \ + // + + #define BOOST_COPY_ASSIGN_REF(TYPE)\ + const ::boost::rv< TYPE >& \ + // + + #define BOOST_COPY_ASSIGN_REF_BEG \ + const ::boost::rv< \ + // + + #define BOOST_COPY_ASSIGN_REF_END \ + >& \ + // + + #define BOOST_MOVE_COPY_ASSIGN_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ + const ::boost::rv< TYPE >& \ + // + + #define BOOST_MOVE_COPY_ASSIGN_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ + const ::boost::rv< TYPE >& \ + // + + ////////////////////////////////////////////////////////////////////////////// + // + // BOOST_MOVABLE_BUT_NOT_COPYABLE + // + ////////////////////////////////////////////////////////////////////////////// + #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ + private:\ + TYPE(TYPE &);\ + TYPE& operator=(TYPE &);\ + public:\ + operator ::boost::rv&() \ + { return *static_cast< ::boost::rv* >(this); }\ + operator const ::boost::rv&() const \ + { return *static_cast* >(this); }\ + private:\ + // + + ////////////////////////////////////////////////////////////////////////////// + // + // BOOST_COPYABLE_AND_MOVABLE + // + ////////////////////////////////////////////////////////////////////////////// + + #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\ + public:\ + TYPE& operator=(TYPE &t)\ + { this->operator=(static_cast &>(const_cast(t))); return *this;}\ + public:\ + operator ::boost::rv&() \ + { return *static_cast< ::boost::rv* >(this); }\ + operator const ::boost::rv&() const \ + { return *static_cast* >(this); }\ + private:\ + // + + #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\ + public:\ + operator ::boost::rv&() \ + { return *static_cast< ::boost::rv* >(this); }\ + operator const ::boost::rv&() const \ + { return *static_cast* >(this); }\ + private:\ + // + +#else //BOOST_NO_CXX11_RVALUE_REFERENCES + + //Compiler workaround detection + #if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) && !defined(__clang__) + //Pre-standard rvalue binding rules + #define BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + #elif defined(_MSC_VER) && (_MSC_VER == 1600) + //Standard rvalue binding rules but with some bugs + #define BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG + //Use standard library for MSVC to avoid namespace issues as + //some move calls in the STL are not fully qualified. + //#define BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE + #endif + #endif + + //! This macro marks a type as movable but not copyable, disabling copy construction + //! and assignment. The user will need to write a move constructor/assignment as explained + //! in the documentation to fully write a movable but not copyable class. + #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ + public:\ + typedef int boost_move_emulation_t;\ + private:\ + TYPE(const TYPE &);\ + TYPE& operator=(const TYPE &);\ + // + + //! This macro marks a type as copyable and movable. + //! The user will need to write a move constructor/assignment and a copy assignment + //! as explained in the documentation to fully write a copyable and movable class. + #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\ + // + + #if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\ + // + #endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + + //!This trait yields to a compile-time true boolean if T was marked as + //!BOOST_MOVABLE_BUT_NOT_COPYABLE or BOOST_COPYABLE_AND_MOVABLE and + //!rvalue references are not available on the platform. False otherwise. + template + struct has_move_emulation_enabled + { + static const bool value = false; + }; + + //!This macro is used to achieve portable syntax in move + //!constructors and assignments for classes marked as + //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE + #define BOOST_RV_REF(TYPE)\ + TYPE && \ + // + + //!This macro is used to achieve portable syntax in move + //!constructors and assignments for template classes marked as + //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. + //!As macros have problems with comma-separatd template arguments, + //!the template argument must be preceded with BOOST_RV_REF_START + //!and ended with BOOST_RV_REF_END + #define BOOST_RV_REF_BEG\ + \ + // + + //!This macro is used to achieve portable syntax in move + //!constructors and assignments for template classes marked as + //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. + //!As macros have problems with comma-separatd template arguments, + //!the template argument must be preceded with BOOST_RV_REF_START + //!and ended with BOOST_RV_REF_END + #define BOOST_RV_REF_END\ + && \ + + //!This macro is used to achieve portable syntax in copy + //!assignment for classes marked as BOOST_COPYABLE_AND_MOVABLE. + #define BOOST_COPY_ASSIGN_REF(TYPE)\ + const TYPE & \ + // + + //! This macro is used to implement portable perfect forwarding + //! as explained in the documentation. + #define BOOST_FWD_REF(TYPE)\ + TYPE && \ + // + + #if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + /// @cond + + #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ + TYPE && \ + // + + #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ + TYPE && \ + // + + #define BOOST_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ + const TYPE & \ + // + + #define BOOST_COPY_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ + TYPE& \ + // + + #define BOOST_CATCH_CONST_RLVALUE(TYPE)\ + const TYPE & \ + // + + /// @endcond + + #endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) + +#endif //BOOST_NO_CXX11_RVALUE_REFERENCES + +#include + +#endif //#ifndef BOOST_MOVE_CORE_HPP diff --git a/include/boost/move/detail/config_begin.hpp b/include/boost/move/detail/config_begin.hpp new file mode 100644 index 0000000..837ee12 --- /dev/null +++ b/include/boost/move/detail/config_begin.hpp @@ -0,0 +1,23 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2012. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#include + +#ifdef BOOST_MSVC + #ifndef _CRT_SECURE_NO_DEPRECATE + #define BOOST_MOVE_CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE + #endif + #ifndef _SCL_SECURE_NO_WARNINGS + #define BOOST_MOVE_SCL_SECURE_NO_WARNINGS + #define _SCL_SECURE_NO_WARNINGS + #endif + #pragma warning (push) + #pragma warning (disable : 4996) // "function": was declared deprecated +#endif diff --git a/include/boost/move/detail/config_end.hpp b/include/boost/move/detail/config_end.hpp new file mode 100644 index 0000000..c43bce0 --- /dev/null +++ b/include/boost/move/detail/config_end.hpp @@ -0,0 +1,20 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2012. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#if defined BOOST_MSVC + #pragma warning (pop) + #ifdef BOOST_MOVE_DETAIL_CRT_SECURE_NO_DEPRECATE + #undef BOOST_MOVE_DETAIL_CRT_SECURE_NO_DEPRECATE + #undef _CRT_SECURE_NO_DEPRECATE + #endif + #ifndef BOOST_MOVE_SCL_SECURE_NO_WARNINGS + #undef BOOST_MOVE_SCL_SECURE_NO_WARNINGS + #undef _SCL_SECURE_NO_WARNINGS + #endif +#endif diff --git a/include/boost/move/detail/meta_utils.hpp b/include/boost/move/detail/meta_utils.hpp new file mode 100644 index 0000000..2bdb654 --- /dev/null +++ b/include/boost/move/detail/meta_utils.hpp @@ -0,0 +1,158 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +//! \file + +#ifndef BOOST_MOVE_DETAIL_META_UTILS_HPP +#define BOOST_MOVE_DETAIL_META_UTILS_HPP + +#include + +//Small meta-typetraits to support move + +namespace boost { +namespace move_detail { + +//if_ +template +struct if_c +{ + typedef T1 type; +}; + +template +struct if_c +{ + typedef T2 type; +}; + +template +struct if_ +{ + typedef typename if_c<0 != T1::value, T2, T3>::type type; +}; + +//enable_if_ +template +struct enable_if_c +{ + typedef T type; +}; + +template +struct enable_if_c {}; + +template +struct enable_if : public enable_if_c {}; + +template +struct disable_if : public enable_if_c {}; + +//integral_constant +template +struct integral_constant +{ + static const T value = v; + typedef T value_type; + typedef integral_constant type; +}; + +//identity +template +struct identity +{ + typedef T type; +}; + +//is_convertible +template +class is_convertible +{ + typedef char true_t; + class false_t { char dummy[2]; }; + static true_t dispatch(U); + static false_t dispatch(...); + static T &trigger(); + public: + enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; +}; + +//and_ not_ +template > +struct and_ + : public integral_constant +{}; + +template +struct not_ + : public integral_constant +{}; + +//is_lvalue_reference +template +struct is_lvalue_reference + : public integral_constant +{}; + +template +struct is_lvalue_reference + : public integral_constant +{}; + +template +struct is_class_or_union +{ + struct twochar { char _[2]; }; + template + static char is_class_or_union_tester(void(U::*)(void)); + template + static twochar is_class_or_union_tester(...); + static const bool value = sizeof(is_class_or_union_tester(0)) == sizeof(char); +}; + +struct empty{}; + +//addressof +template struct addr_impl_ref +{ + T & v_; + inline addr_impl_ref( T & v ): v_( v ) {} + inline operator T& () const { return v_; } + + private: + addr_impl_ref & operator=(const addr_impl_ref &); +}; + +template struct addressof_impl +{ + static inline T * f( T & v, long ) + { + return reinterpret_cast( + &const_cast(reinterpret_cast(v))); + } + + static inline T * f( T * v, int ) + { return v; } +}; + +template +inline T * addressof( T & v ) +{ + return ::boost::move_detail::addressof_impl::f + ( ::boost::move_detail::addr_impl_ref( v ), 0 ); +} + +} //namespace move_detail { +} //namespace boost { + +#include + +#endif //#ifndef BOOST_MOVE_DETAIL_META_UTILS_HPP diff --git a/include/boost/move/move_helpers.hpp b/include/boost/move/detail/move_helpers.hpp similarity index 97% rename from include/boost/move/move_helpers.hpp rename to include/boost/move/detail/move_helpers.hpp index 8f78c53..ddfea9b 100644 --- a/include/boost/move/move_helpers.hpp +++ b/include/boost/move/detail/move_helpers.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2010-2011. +// (C) Copyright Ion Gaztanaga 2010-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -12,8 +12,10 @@ #ifndef BOOST_MOVE_MOVE_HELPERS_HPP #define BOOST_MOVE_MOVE_HELPERS_HPP -#include +#include #include +#include +#include #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || (defined(_MSC_VER) && (_MSC_VER == 1600)) #include diff --git a/include/boost/move/iterator.hpp b/include/boost/move/iterator.hpp new file mode 100644 index 0000000..b4bc1af --- /dev/null +++ b/include/boost/move/iterator.hpp @@ -0,0 +1,298 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +//! \file + +#ifndef BOOST_MOVE_ITERATOR_HPP +#define BOOST_MOVE_ITERATOR_HPP + +#include +#include +#include //std::iterator + +namespace boost { + +////////////////////////////////////////////////////////////////////////////// +// +// move_iterator +// +////////////////////////////////////////////////////////////////////////////// + +//! Class template move_iterator is an iterator adaptor with the same behavior +//! as the underlying iterator except that its dereference operator implicitly +//! converts the value returned by the underlying iterator's dereference operator +//! to an rvalue reference. Some generic algorithms can be called with move +//! iterators to replace copying with moving. +template +class move_iterator +{ + public: + typedef It iterator_type; + typedef typename std::iterator_traits::value_type value_type; + #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_DOXYGEN_INVOKED) + typedef value_type && reference; + #else + typedef typename ::boost::move_detail::if_ + < ::boost::has_move_emulation_enabled + , ::boost::rv& + , value_type & >::type reference; + #endif + typedef It pointer; + typedef typename std::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::iterator_category iterator_category; + + move_iterator() + {} + + explicit move_iterator(It i) + : m_it(i) + {} + + template + move_iterator(const move_iterator& u) + : m_it(u.base()) + {} + + iterator_type base() const + { return m_it; } + + reference operator*() const + { + #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) + return *m_it; + #else + return ::boost::move(*m_it); + #endif + } + + pointer operator->() const + { return m_it; } + + move_iterator& operator++() + { ++m_it; return *this; } + + move_iterator operator++(int) + { move_iterator tmp(*this); ++(*this); return tmp; } + + move_iterator& operator--() + { --m_it; return *this; } + + move_iterator operator--(int) + { move_iterator tmp(*this); --(*this); return tmp; } + + move_iterator operator+ (difference_type n) const + { return move_iterator(m_it + n); } + + move_iterator& operator+=(difference_type n) + { m_it += n; return *this; } + + move_iterator operator- (difference_type n) const + { return move_iterator(m_it - n); } + + move_iterator& operator-=(difference_type n) + { m_it -= n; return *this; } + + reference operator[](difference_type n) const + { + #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) + return m_it[n]; + #else + return ::boost::move(m_it[n]); + #endif + } + + friend bool operator==(const move_iterator& x, const move_iterator& y) + { return x.base() == y.base(); } + + friend bool operator!=(const move_iterator& x, const move_iterator& y) + { return x.base() != y.base(); } + + friend bool operator< (const move_iterator& x, const move_iterator& y) + { return x.base() < y.base(); } + + friend bool operator<=(const move_iterator& x, const move_iterator& y) + { return x.base() <= y.base(); } + + friend bool operator> (const move_iterator& x, const move_iterator& y) + { return x.base() > y.base(); } + + friend bool operator>=(const move_iterator& x, const move_iterator& y) + { return x.base() >= y.base(); } + + friend difference_type operator-(const move_iterator& x, const move_iterator& y) + { return x.base() - y.base(); } + + friend move_iterator operator+(difference_type n, const move_iterator& x) + { return move_iterator(x.base() + n); } + + private: + It m_it; +}; + +//is_move_iterator +namespace move_detail { + +template +struct is_move_iterator + : public ::boost::move_detail::integral_constant +{ +}; + +template +struct is_move_iterator< ::boost::move_iterator > + : public ::boost::move_detail::integral_constant +{ +}; + +} //namespace move_detail { + +////////////////////////////////////////////////////////////////////////////// +// +// move_iterator +// +////////////////////////////////////////////////////////////////////////////// + +//! +//! Returns: move_iterator(i). +template +inline move_iterator make_move_iterator(const It &it) +{ return move_iterator(it); } + +////////////////////////////////////////////////////////////////////////////// +// +// back_move_insert_iterator +// +////////////////////////////////////////////////////////////////////////////// + + +//! A move insert iterator that move constructs elements at the +//! back of a container +template // C models Container +class back_move_insert_iterator + : public std::iterator +{ + C* container_m; + + public: + typedef C container_type; + typedef typename C::value_type value_type; + typedef typename C::reference reference; + + explicit back_move_insert_iterator(C& x) : container_m(&x) { } + + back_move_insert_iterator& operator=(reference x) + { container_m->push_back(boost::move(x)); return *this; } + + back_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) + { reference rx = x; return this->operator=(rx); } + + back_move_insert_iterator& operator*() { return *this; } + back_move_insert_iterator& operator++() { return *this; } + back_move_insert_iterator& operator++(int) { return *this; } +}; + +//! +//! Returns: back_move_insert_iterator(x). +template // C models Container +inline back_move_insert_iterator back_move_inserter(C& x) +{ + return back_move_insert_iterator(x); +} + +////////////////////////////////////////////////////////////////////////////// +// +// front_move_insert_iterator +// +////////////////////////////////////////////////////////////////////////////// + +//! A move insert iterator that move constructs elements int the +//! front of a container +template // C models Container +class front_move_insert_iterator + : public std::iterator +{ + C* container_m; + +public: + typedef C container_type; + typedef typename C::value_type value_type; + typedef typename C::reference reference; + + explicit front_move_insert_iterator(C& x) : container_m(&x) { } + + front_move_insert_iterator& operator=(reference x) + { container_m->push_front(boost::move(x)); return *this; } + + front_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) + { reference rx = x; return this->operator=(rx); } + + front_move_insert_iterator& operator*() { return *this; } + front_move_insert_iterator& operator++() { return *this; } + front_move_insert_iterator& operator++(int) { return *this; } +}; + +//! +//! Returns: front_move_insert_iterator(x). +template // C models Container +inline front_move_insert_iterator front_move_inserter(C& x) +{ + return front_move_insert_iterator(x); +} + +////////////////////////////////////////////////////////////////////////////// +// +// insert_move_iterator +// +////////////////////////////////////////////////////////////////////////////// +template // C models Container +class move_insert_iterator + : public std::iterator +{ + C* container_m; + typename C::iterator pos_; + + public: + typedef C container_type; + typedef typename C::value_type value_type; + typedef typename C::reference reference; + + explicit move_insert_iterator(C& x, typename C::iterator pos) + : container_m(&x), pos_(pos) + {} + + move_insert_iterator& operator=(reference x) + { + pos_ = container_m->insert(pos_, ::boost::move(x)); + ++pos_; + return *this; + } + + move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) + { reference rx = x; return this->operator=(rx); } + + move_insert_iterator& operator*() { return *this; } + move_insert_iterator& operator++() { return *this; } + move_insert_iterator& operator++(int) { return *this; } +}; + +//! +//! Returns: move_insert_iterator(x, it). +template // C models Container +inline move_insert_iterator move_inserter(C& x, typename C::iterator it) +{ + return move_insert_iterator(x, it); +} + +} //namespace boost { + +#include + +#endif //#ifndef BOOST_MOVE_ITERATOR_HPP diff --git a/include/boost/move/move.hpp b/include/boost/move/move.hpp index b0f086c..66e99a7 100644 --- a/include/boost/move/move.hpp +++ b/include/boost/move/move.hpp @@ -1,7 +1,7 @@ ////////////////////////////////////////////////////////////////////////////// // // (C) Copyright David Abrahams, Vicente Botet 2009. -// (C) Copyright Ion Gaztanaga 2009-2010. +// (C) Copyright Ion Gaztanaga 2009-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -10,1264 +10,18 @@ // ////////////////////////////////////////////////////////////////////////////// -//! \file +//! \file move.hpp +//! A general library header that includes +//! the rest of top-level headers. #ifndef BOOST_MOVE_MOVE_HPP #define BOOST_MOVE_MOVE_HPP -#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) - -/// @cond - -#include - -#ifdef BOOST_MSVC - #ifndef _CRT_SECURE_NO_DEPRECATE - #define BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE - #define _CRT_SECURE_NO_DEPRECATE - #endif - #ifndef _SCL_SECURE_NO_WARNINGS - #define BOOST_INTERPROCESS_SCL_SECURE_NO_WARNINGS - #define _SCL_SECURE_NO_WARNINGS - #endif - #pragma warning (push) - #pragma warning(disable:4996) -#endif - -#include //copy, copy_backward -#include //uninitialized_copy -#include //std::iterator - -#define BOOST_MOVE_AVOID_BOOST_DEPENDENCIES - -//If boost dependencies are avoided include all machinery -#if !defined(BOOST_MOVE_AVOID_BOOST_DEPENDENCIES) - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #define BOOST_MOVE_MPL_NS ::boost::mpl - #define BOOST_MOVE_BOOST_NS ::boost -#else - #define BOOST_MOVE_MPL_NS ::boost::move_detail - #define BOOST_MOVE_BOOST_NS ::boost::move_detail -#endif //#ifdef BOOST_MOVE_AVOID_BOOST_DEPENDENCIES - -//Small meta-typetraits to support move -#ifdef BOOST_MOVE_AVOID_BOOST_DEPENDENCIES - - namespace boost { - namespace move_detail { - - //if_ - template - struct if_c - { - typedef T1 type; - }; - - template - struct if_c - { - typedef T2 type; - }; - - template - struct if_ - { - typedef typename if_c<0 != T1::value, T2, T3>::type type; - }; - - //enable_if_ - template - struct enable_if_c - { - typedef T type; - }; - - template - struct enable_if_c {}; - - template - struct enable_if : public enable_if_c {}; - - template - struct disable_if : public enable_if_c {}; - - //integral_constant - template - struct integral_constant - { - static const T value = v; - typedef T value_type; - typedef integral_constant type; - }; - - //identity - template - struct identity - { - typedef T type; - }; - - //is_convertible - template - class is_convertible - { - typedef char true_t; - class false_t { char dummy[2]; }; - static true_t dispatch(U); - static false_t dispatch(...); - static T &trigger(); - public: - enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; - }; - - //and_ not_ - template > - struct and_ - : public integral_constant - {}; - - template - struct not_ - : public integral_constant - {}; - - //is_lvalue_reference - template - struct is_lvalue_reference - : public integral_constant - {}; - - template - struct is_lvalue_reference - : public integral_constant - {}; - - //has_trivial_destructor - template - struct has_trivial_destructor - : public integral_constant - {}; - - //addressof - template struct addr_impl_ref - { - T & v_; - inline addr_impl_ref( T & v ): v_( v ) {} - inline operator T& () const { return v_; } - - private: - addr_impl_ref & operator=(const addr_impl_ref &); - }; - - template struct addressof_impl - { - static inline T * f( T & v, long ) - { - return reinterpret_cast( - &const_cast(reinterpret_cast(v))); - } - - static inline T * f( T * v, int ) - { return v; } - }; - - template - inline T * addressof( T & v ) - { - return ::boost::move_detail::addressof_impl::f - ( ::boost::move_detail::addr_impl_ref( v ), 0 ); - } - - } //namespace move_detail { - } //namespace boost { - -#endif //BOOST_MOVE_AVOID_BOOST_DEPENDENCIES - -//Compiler workaround detection -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - - #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) && !defined(__clang__) - //Pre-standard rvalue binding rules - #define BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES - #elif defined(_MSC_VER) && (_MSC_VER == 1600) - //Standard rvalue binding rules but with some bugs - #define BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG - //Use standard library for MSVC to avoid namespace issues as - //some move calls in the STL are not fully qualified. - //#define BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE - #endif - -#endif - -/// @endcond - -#endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) - - //Move emulation rv breaks standard aliasing rules so add workarounds for some compilers - #if defined(__GNUC__) && (__GNUC__ >= 4) - #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__)) - #else - #define BOOST_MOVE_ATTRIBUTE_MAY_ALIAS - #endif - - namespace boost { - - namespace move_detail { - template - struct is_class_or_union - { - struct twochar { char _[2]; }; - template - static char is_class_or_union_tester(void(U::*)(void)); - template - static twochar is_class_or_union_tester(...); - static const bool value = sizeof(is_class_or_union_tester(0)) == sizeof(char); - }; - struct empty{}; - } - - ////////////////////////////////////////////////////////////////////////////// - // - // struct rv - // - ////////////////////////////////////////////////////////////////////////////// - template - class rv - : public BOOST_MOVE_MPL_NS::if_c - < ::boost::move_detail::is_class_or_union::value - , T - , ::boost::move_detail::empty - >::type - { - rv(); - ~rv(); - rv(rv const&); - void operator=(rv const&); - } BOOST_MOVE_ATTRIBUTE_MAY_ALIAS; - - - - ////////////////////////////////////////////////////////////////////////////// - // - // move_detail::is_rv - // - ////////////////////////////////////////////////////////////////////////////// - - namespace move_detail { - - template - struct is_rv - : BOOST_MOVE_BOOST_NS::integral_constant - {}; - - template - struct is_rv< rv > - : BOOST_MOVE_BOOST_NS::integral_constant - {}; - - template - struct is_rv< const rv > - : BOOST_MOVE_BOOST_NS::integral_constant - {}; - - } //namespace move_detail { - - ////////////////////////////////////////////////////////////////////////////// - // - // has_move_emulation_enabled - // - ////////////////////////////////////////////////////////////////////////////// - template - struct has_move_emulation_enabled - : BOOST_MOVE_BOOST_NS::is_convertible< T, ::boost::rv& > - {}; - - template - struct has_move_emulation_enabled - : BOOST_MOVE_BOOST_NS::integral_constant - {}; - - template - struct has_move_emulation_enabled< ::boost::rv > - : BOOST_MOVE_BOOST_NS::integral_constant - {}; - - template - struct has_move_emulation_enabled_aux - : has_move_emulation_enabled {}; - - template - struct has_nothrow_move - : public BOOST_MOVE_BOOST_NS::integral_constant - {}; - - ////////////////////////////////////////////////////////////////////////////// - // - // move() - // - ////////////////////////////////////////////////////////////////////////////// - - template - inline typename BOOST_MOVE_BOOST_NS::disable_if, T&>::type move(T& x) - { - return x; - } - - template - inline typename BOOST_MOVE_BOOST_NS::enable_if, rv&>::type move(T& x) - { - return *static_cast* >(BOOST_MOVE_BOOST_NS::addressof(x)); - } - - template - inline typename BOOST_MOVE_BOOST_NS::enable_if, rv&>::type move(rv& x) - { - return x; - } - - #define BOOST_RV_REF(TYPE)\ - ::boost::rv< TYPE >& \ - // - - #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ - ::boost::rv< TYPE >& \ - // - - #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ - ::boost::rv< TYPE >& \ - // - - #define BOOST_RV_REF_BEG\ - ::boost::rv< \ - // - - #define BOOST_RV_REF_END\ - >& \ - // - - - - #define BOOST_FWD_REF(TYPE)\ - const TYPE & \ - // - - #define BOOST_CATCH_CONST_RLVALUE(TYPE)\ - const ::boost::rv< TYPE >& \ - // - - #define BOOST_COPY_ASSIGN_REF(TYPE)\ - const ::boost::rv< TYPE >& \ - // - - #define BOOST_COPY_ASSIGN_REF_BEG \ - const ::boost::rv< \ - // - - #define BOOST_COPY_ASSIGN_REF_END \ - >& \ - // - - #define BOOST_MOVE_COPY_ASSIGN_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ - const ::boost::rv< TYPE >& \ - // - - #define BOOST_MOVE_COPY_ASSIGN_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ - const ::boost::rv< TYPE >& \ - // - - ////////////////////////////////////////////////////////////////////////////// - // - // forward() - // - ////////////////////////////////////////////////////////////////////////////// - - template - inline typename BOOST_MOVE_BOOST_NS::enable_if< ::boost::move_detail::is_rv, T &>::type - forward(const typename BOOST_MOVE_MPL_NS::identity::type &x) - { - return const_cast(x); - } - - template - inline typename BOOST_MOVE_BOOST_NS::disable_if< ::boost::move_detail::is_rv, const T &>::type - forward(const typename BOOST_MOVE_MPL_NS::identity::type &x) - { - return x; - } - - ////////////////////////////////////////////////////////////////////////////// - // - // BOOST_MOVABLE_BUT_NOT_COPYABLE - // - ////////////////////////////////////////////////////////////////////////////// - #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ - private:\ - TYPE(TYPE &);\ - TYPE& operator=(TYPE &);\ - public:\ - operator ::boost::rv&() \ - { return *static_cast< ::boost::rv* >(this); }\ - operator const ::boost::rv&() const \ - { return *static_cast* >(this); }\ - private:\ - // - - ////////////////////////////////////////////////////////////////////////////// - // - // BOOST_COPYABLE_AND_MOVABLE - // - ////////////////////////////////////////////////////////////////////////////// - - #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\ - public:\ - TYPE& operator=(TYPE &t)\ - { this->operator=(static_cast &>(const_cast(t))); return *this;}\ - public:\ - operator ::boost::rv&() \ - { return *static_cast< ::boost::rv* >(this); }\ - operator const ::boost::rv&() const \ - { return *static_cast* >(this); }\ - private:\ - // - - #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\ - public:\ - operator ::boost::rv&() \ - { return *static_cast< ::boost::rv* >(this); }\ - operator const ::boost::rv&() const \ - { return *static_cast* >(this); }\ - private:\ - // - - } //namespace boost - -#else //BOOST_NO_CXX11_RVALUE_REFERENCES - - namespace boost{ - - //! By default this traits returns false. Classes with non-throwing move constructor - //! and assignment should specialize this trait to obtain some performance improvements. - template - struct has_nothrow_move - : public BOOST_MOVE_MPL_NS::integral_constant - {}; - - } // namespace boost{ - - #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) - #include - - namespace boost{ - - using ::std::move; - using ::std::forward; - using ::std::move_backward; - - } //namespace boost - - #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE - - #include - - namespace boost { - - ////////////////////////////////////////////////////////////////////////////// - // - // move - // - ////////////////////////////////////////////////////////////////////////////// - - #if defined(BOOST_MOVE_DOXYGEN_INVOKED) - //! This function provides a way to convert a reference into a rvalue reference - //! 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); - - #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) - { return t; } - - #else //Old move - - template - inline typename remove_reference::type && move(T&& t) - { return static_cast::type &&>(t); } - - #endif //Old move - - ////////////////////////////////////////////////////////////////////////////// - // - // forward - // - ////////////////////////////////////////////////////////////////////////////// - - - #if defined(BOOST_MOVE_DOXYGEN_INVOKED) - //! This function provides limited form of forwarding that is usually enough for - //! in-place construction and avoids the exponential overloading necessary for - //! perfect forwarding in C++03. - //! - //! For compilers with rvalue references this function provides perfect forwarding. - //! - //! Otherwise: - //! * If input_reference binds to const ::boost::rv & then it output_reference is - //! ::boost::rev & - //! - //! * Else, input_reference is equal to output_reference is equal to input_reference. - template output_reference forward(input_reference); - #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_MPL_NS::identity::type&& t) - { return t; } - - #else //Old move - - //Implementation #5 from N2951, thanks to Howard Hinnant - - template - inline T&& forward(U&& t - , typename BOOST_MOVE_BOOST_NS::enable_if_c< - move_detail::is_lvalue_reference::value ? move_detail::is_lvalue_reference::value : true>::type * = 0/* - , typename BOOST_MOVE_BOOST_NS::enable_if_c< - move_detail::is_convertible - ::type*, typename remove_reference::type*>::value>::type * = 0*/) - { return static_cast(t); } - - #endif //BOOST_MOVE_DOXYGEN_INVOKED - - } //namespace boost { - - #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) - - //! This macro marks a type as movable but not copyable, disabling copy construction - //! and assignment. The user will need to write a move constructor/assignment as explained - //! in the documentation to fully write a movable but not copyable class. - #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ - public:\ - typedef int boost_move_emulation_t;\ - private:\ - TYPE(const TYPE &);\ - TYPE& operator=(const TYPE &);\ - // - - //! This macro marks a type as copyable and movable. - //! The user will need to write a move constructor/assignment and a copy assignment - //! as explained in the documentation to fully write a copyable and movable class. - #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\ - // - - #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\ - // - - //!This macro is used to achieve portable syntax in move - //!constructors and assignments for classes marked as - //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE - #define BOOST_RV_REF(TYPE)\ - TYPE && \ - // - - //!This macro is used to achieve portable syntax in move - //!constructors and assignments for template classes marked as - //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. - //!As macros have problem with comma-separatd template arguments, - //!the template argument must be preceded with BOOST_RV_REF_START - //!and ended with BOOST_RV_REF_END - #define BOOST_RV_REF_BEG\ - \ - // - - //!This macro is used to achieve portable syntax in move - //!constructors and assignments for template classes marked as - //!BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. - //!As macros have problem with comma-separatd template arguments, - //!the template argument must be preceded with BOOST_RV_REF_START - //!and ended with BOOST_RV_REF_END - #define BOOST_RV_REF_END\ - && \ - - //!This macro is used to achieve portable syntax in copy - //!assignment for classes marked as BOOST_COPYABLE_AND_MOVABLE. - #define BOOST_COPY_ASSIGN_REF(TYPE)\ - const TYPE & \ - // - - //! This macro is used to implement portable perfect forwarding - //! as explained in the documentation. - #define BOOST_FWD_REF(TYPE)\ - TYPE && \ - // - - - #if !defined(BOOST_MOVE_DOXYGEN_INVOKED) - /// @cond - - #define BOOST_RV_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ - TYPE && \ - // - - #define BOOST_RV_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ - TYPE && \ - // - - #define BOOST_COPY_REF_2_TEMPL_ARGS(TYPE, ARG1, ARG2)\ - const TYPE & \ - // - - #define BOOST_COPY_REF_3_TEMPL_ARGS(TYPE, ARG1, ARG2, ARG3)\ - TYPE& \ - // - - #define BOOST_CATCH_CONST_RLVALUE(TYPE)\ - const TYPE & \ - // - - /// @endcond - - #endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED) - -#endif //BOOST_NO_CXX11_RVALUE_REFERENCES - -namespace boost { - -////////////////////////////////////////////////////////////////////////////// -// -// move_iterator -// -////////////////////////////////////////////////////////////////////////////// - -//! Class template move_iterator is an iterator adaptor with the same behavior -//! as the underlying iterator except that its dereference operator implicitly -//! converts the value returned by the underlying iterator's dereference operator -//! to an rvalue reference. Some generic algorithms can be called with move -//! iterators to replace copying with moving. -template -class move_iterator -{ - public: - typedef It iterator_type; - typedef typename std::iterator_traits::value_type value_type; - #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_DOXYGEN_INVOKED) - typedef value_type && reference; - #else - typedef typename BOOST_MOVE_MPL_NS::if_ - < ::boost::has_move_emulation_enabled - , ::boost::rv& - , value_type & >::type reference; - #endif - typedef It pointer; - typedef typename std::iterator_traits::difference_type difference_type; - typedef typename std::iterator_traits::iterator_category iterator_category; - - move_iterator() - {} - - explicit move_iterator(It i) - : m_it(i) - {} - - template - move_iterator(const move_iterator& u) - : m_it(u.base()) - {} - - iterator_type base() const - { return m_it; } - - reference operator*() const - { - #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) - return *m_it; - #else - return ::boost::move(*m_it); - #endif - } - - pointer operator->() const - { return m_it; } - - move_iterator& operator++() - { ++m_it; return *this; } - - move_iterator operator++(int) - { move_iterator tmp(*this); ++(*this); return tmp; } - - move_iterator& operator--() - { --m_it; return *this; } - - move_iterator operator--(int) - { move_iterator tmp(*this); --(*this); return tmp; } - - move_iterator operator+ (difference_type n) const - { return move_iterator(m_it + n); } - - move_iterator& operator+=(difference_type n) - { m_it += n; return *this; } - - move_iterator operator- (difference_type n) const - { return move_iterator(m_it - n); } - - move_iterator& operator-=(difference_type n) - { m_it -= n; return *this; } - - reference operator[](difference_type n) const - { - #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) - return m_it[n]; - #else - return ::boost::move(m_it[n]); - #endif - } - - friend bool operator==(const move_iterator& x, const move_iterator& y) - { return x.base() == y.base(); } - - friend bool operator!=(const move_iterator& x, const move_iterator& y) - { return x.base() != y.base(); } - - friend bool operator< (const move_iterator& x, const move_iterator& y) - { return x.base() < y.base(); } - - friend bool operator<=(const move_iterator& x, const move_iterator& y) - { return x.base() <= y.base(); } - - friend bool operator> (const move_iterator& x, const move_iterator& y) - { return x.base() > y.base(); } - - friend bool operator>=(const move_iterator& x, const move_iterator& y) - { return x.base() >= y.base(); } - - friend difference_type operator-(const move_iterator& x, const move_iterator& y) - { return x.base() - y.base(); } - - friend move_iterator operator+(difference_type n, const move_iterator& x) - { return move_iterator(x.base() + n); } - - private: - It m_it; -}; - - -//is_move_iterator -namespace move_detail { - -template -struct is_move_iterator - : public BOOST_MOVE_BOOST_NS::integral_constant -{ -}; - -template -struct is_move_iterator< ::boost::move_iterator > - : public BOOST_MOVE_BOOST_NS::integral_constant -{ -}; - -} //namespace move_detail { - -////////////////////////////////////////////////////////////////////////////// -// -// move_iterator -// -////////////////////////////////////////////////////////////////////////////// - -//! -//! Returns: move_iterator(i). -template -inline move_iterator make_move_iterator(const It &it) -{ return move_iterator(it); } - -////////////////////////////////////////////////////////////////////////////// -// -// back_move_insert_iterator -// -////////////////////////////////////////////////////////////////////////////// - - -//! A move insert iterator that move constructs elements at the -//! back of a container -template // C models Container -class back_move_insert_iterator - : public std::iterator -{ - C* container_m; - - public: - typedef C container_type; - typedef typename C::value_type value_type; - typedef typename C::reference reference; - - explicit back_move_insert_iterator(C& x) : container_m(&x) { } - - back_move_insert_iterator& operator=(reference x) - { container_m->push_back(boost::move(x)); return *this; } - - back_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) - { reference rx = x; return this->operator=(rx); } - - back_move_insert_iterator& operator*() { return *this; } - back_move_insert_iterator& operator++() { return *this; } - back_move_insert_iterator& operator++(int) { return *this; } -}; - -//! -//! Returns: back_move_insert_iterator(x). -template // C models Container -inline back_move_insert_iterator back_move_inserter(C& x) -{ - return back_move_insert_iterator(x); -} - -////////////////////////////////////////////////////////////////////////////// -// -// front_move_insert_iterator -// -////////////////////////////////////////////////////////////////////////////// - -//! A move insert iterator that move constructs elements int the -//! front of a container -template // C models Container -class front_move_insert_iterator - : public std::iterator -{ - C* container_m; - -public: - typedef C container_type; - typedef typename C::value_type value_type; - typedef typename C::reference reference; - - explicit front_move_insert_iterator(C& x) : container_m(&x) { } - - front_move_insert_iterator& operator=(reference x) - { container_m->push_front(boost::move(x)); return *this; } - - front_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) - { reference rx = x; return this->operator=(rx); } - - front_move_insert_iterator& operator*() { return *this; } - front_move_insert_iterator& operator++() { return *this; } - front_move_insert_iterator& operator++(int) { return *this; } -}; - -//! -//! Returns: front_move_insert_iterator(x). -template // C models Container -inline front_move_insert_iterator front_move_inserter(C& x) -{ - return front_move_insert_iterator(x); -} - -////////////////////////////////////////////////////////////////////////////// -// -// insert_move_iterator -// -////////////////////////////////////////////////////////////////////////////// -template // C models Container -class move_insert_iterator - : public std::iterator -{ - C* container_m; - typename C::iterator pos_; - - public: - typedef C container_type; - typedef typename C::value_type value_type; - typedef typename C::reference reference; - - explicit move_insert_iterator(C& x, typename C::iterator pos) - : container_m(&x), pos_(pos) - {} - - move_insert_iterator& operator=(reference x) - { - pos_ = container_m->insert(pos_, ::boost::move(x)); - ++pos_; - return *this; - } - - move_insert_iterator& operator=(BOOST_RV_REF(value_type) x) - { reference rx = x; return this->operator=(rx); } - - move_insert_iterator& operator*() { return *this; } - move_insert_iterator& operator++() { return *this; } - move_insert_iterator& operator++(int) { return *this; } -}; - -//! -//! Returns: move_insert_iterator(x, it). -template // C models Container -inline move_insert_iterator move_inserter(C& x, typename C::iterator it) -{ - return move_insert_iterator(x, it); -} - -////////////////////////////////////////////////////////////////////////////// -// -// move -// -////////////////////////////////////////////////////////////////////////////// - -#if !defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) - - //! Effects: Moves elements in the range [first,last) into the range [result,result + (last - - //! first)) starting from first and proceeding to last. For each non-negative integer n < (last-first), - //! performs *(result + n) = ::boost::move (*(first + n)). - //! - //! Effects: result + (last - first). - //! - //! Requires: result shall not be in the range [first,last). - //! - //! Complexity: Exactly last - first move assignments. - template // O models OutputIterator - O move(I f, I l, O result) - { - while (f != l) { - *result = ::boost::move(*f); - ++f; ++result; - } - return result; - } - - ////////////////////////////////////////////////////////////////////////////// - // - // move_backward - // - ////////////////////////////////////////////////////////////////////////////// - - //! Effects: Moves elements in the range [first,last) into the range - //! [result - (last-first),result) starting from last - 1 and proceeding to - //! first. For each positive integer n <= (last - first), - //! performs *(result - n) = ::boost::move(*(last - n)). - //! - //! Requires: result shall not be in the range [first,last). - //! - //! Returns: result - (last - first). - //! - //! Complexity: Exactly last - first assignments. - template // O models BidirectionalIterator - O move_backward(I f, I l, O result) - { - while (f != l) { - --l; --result; - *result = ::boost::move(*l); - } - return result; - } - -#endif //!defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) - -////////////////////////////////////////////////////////////////////////////// -// -// uninitialized_move -// -////////////////////////////////////////////////////////////////////////////// - -//! Effects: -//! \code -//! for (; first != last; ++result, ++first) -//! new (static_cast(&*result)) -//! typename iterator_traits::value_type(boost::move(*first)); -//! \endcode -//! -//! Returns: result -template - // F models ForwardIterator -F uninitialized_move(I f, I l, F r - /// @cond -// ,typename BOOST_MOVE_BOOST_NS::enable_if::value_type> >::type* = 0 - /// @endcond - ) -{ - typedef typename std::iterator_traits::value_type input_value_type; - while (f != l) { - ::new(static_cast(&*r)) input_value_type(boost::move(*f)); - ++f; ++r; - } - return r; -} - -/// @cond -/* -template - // F models ForwardIterator -F uninitialized_move(I f, I l, F r, - typename BOOST_MOVE_BOOST_NS::disable_if::value_type> >::type* = 0) -{ - return std::uninitialized_copy(f, l, r); -} -*/ - -////////////////////////////////////////////////////////////////////////////// -// -// uninitialized_copy_or_move -// -////////////////////////////////////////////////////////////////////////////// - -namespace move_detail { - -template - // F models ForwardIterator -inline F uninitialized_move_move_iterator(I f, I l, F r -// ,typename BOOST_MOVE_BOOST_NS::enable_if< has_move_emulation_enabled >::type* = 0 -) -{ - return ::boost::uninitialized_move(f, l, r); -} -/* -template - // F models ForwardIterator -F uninitialized_move_move_iterator(I f, I l, F r, - typename BOOST_MOVE_BOOST_NS::disable_if< has_move_emulation_enabled >::type* = 0) -{ - return std::uninitialized_copy(f.base(), l.base(), r); -} -*/ -} //namespace move_detail { - -template - // F models ForwardIterator -inline F uninitialized_copy_or_move(I f, I l, F r, - typename BOOST_MOVE_BOOST_NS::enable_if< move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::move_detail::uninitialized_move_move_iterator(f, l, r); -} - -////////////////////////////////////////////////////////////////////////////// -// -// copy_or_move -// -////////////////////////////////////////////////////////////////////////////// - -namespace move_detail { - -template - // F models ForwardIterator -inline F move_move_iterator(I f, I l, F r -// ,typename BOOST_MOVE_BOOST_NS::enable_if< has_move_emulation_enabled >::type* = 0 -) -{ - return ::boost::move(f, l, r); -} -/* -template - // F models ForwardIterator -F move_move_iterator(I f, I l, F r, - typename BOOST_MOVE_BOOST_NS::disable_if< has_move_emulation_enabled >::type* = 0) -{ - return std::copy(f.base(), l.base(), r); -} -*/ - -} //namespace move_detail { - -template - // F models ForwardIterator -inline F copy_or_move(I f, I l, F r, - typename BOOST_MOVE_BOOST_NS::enable_if< move_detail::is_move_iterator >::type* = 0) -{ - return ::boost::move_detail::move_move_iterator(f, l, r); -} - -/// @endcond - -//! Effects: -//! \code -//! for (; first != last; ++result, ++first) -//! new (static_cast(&*result)) -//! typename iterator_traits::value_type(*first); -//! \endcode -//! -//! Returns: result -//! -//! Note: This function is provided because -//! std::uninitialized_copy from some STL implementations -//! is not compatible with move_iterator -template - // F models ForwardIterator -inline F uninitialized_copy_or_move(I f, I l, F r - /// @cond - ,typename BOOST_MOVE_BOOST_NS::disable_if< move_detail::is_move_iterator >::type* = 0 - /// @endcond - ) -{ - return std::uninitialized_copy(f, l, r); -} - -//! Effects: -//! \code -//! for (; first != last; ++result, ++first) -//! *result = *first; -//! \endcode -//! -//! Returns: result -//! -//! Note: This function is provided because -//! std::uninitialized_copy from some STL implementations -//! is not compatible with move_iterator -template - // F models ForwardIterator -inline F copy_or_move(I f, I l, F r - /// @cond - ,typename BOOST_MOVE_BOOST_NS::disable_if< move_detail::is_move_iterator >::type* = 0 - /// @endcond - ) -{ - return std::copy(f, l, r); -} - -//! If this trait yields to true -//! (has_trivial_destructor_after_move <T>::value == true) -//! means that if T is used as argument of a move construction/assignment, -//! there is no need to call T's destructor. -//! This optimization tipically is used to improve containers' performance. -//! -//! By default this trait is true if the type has trivial destructor, -//! every class should specialize this trait if it wants to improve performance -//! when inserted in containers. -template -struct has_trivial_destructor_after_move - : BOOST_MOVE_BOOST_NS::has_trivial_destructor -{}; - - - -namespace move_detail { - -// Code from Jeffrey Lee Hellrung, many thanks - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template< class T> struct forward_type { typedef T type; }; -#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template< class T> - struct forward_type - { typedef const T &type; }; - - template< class T> - struct forward_type< boost::rv > - { typedef T type; }; -#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - - - -// Code from Jeffrey Lee Hellrung, many thanks - -template< class T > struct is_rvalue_reference : BOOST_MOVE_BOOST_NS::integral_constant { }; -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template< class T > struct is_rvalue_reference< T&& > : BOOST_MOVE_BOOST_NS::integral_constant { }; -#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template< class T > struct is_rvalue_reference< boost::rv& > - : BOOST_MOVE_BOOST_NS::integral_constant - {}; - - template< class T > struct is_rvalue_reference< const boost::rv& > - : BOOST_MOVE_BOOST_NS::integral_constant - {}; -#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template< class T > struct add_rvalue_reference { typedef T&& type; }; -#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - namespace detail_add_rvalue_reference - { - template< class T - , bool emulation = ::boost::has_move_emulation_enabled::value - , bool rv = ::boost::move_detail::is_rv::value > - struct add_rvalue_reference_impl { typedef T type; }; - - template< class T, bool emulation> - struct add_rvalue_reference_impl< T, emulation, true > { typedef T & type; }; - - template< class T, bool rv > - struct add_rvalue_reference_impl< T, true, rv > { typedef ::boost::rv& type; }; - } // namespace detail_add_rvalue_reference - - template< class T > - struct add_rvalue_reference - : detail_add_rvalue_reference::add_rvalue_reference_impl - { }; - - template< class T > - struct add_rvalue_reference - { typedef T & type; }; - -#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -template< class T > struct remove_rvalue_reference { typedef T type; }; - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template< class T > struct remove_rvalue_reference< T&& > { typedef T type; }; -#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template< class T > struct remove_rvalue_reference< rv > { typedef T type; }; - template< class T > struct remove_rvalue_reference< const rv > { typedef T type; }; - template< class T > struct remove_rvalue_reference< volatile rv > { typedef T type; }; - template< class T > struct remove_rvalue_reference< const volatile rv > { typedef T type; }; - template< class T > struct remove_rvalue_reference< rv& > { typedef T type; }; - template< class T > struct remove_rvalue_reference< const rv& > { typedef T type; }; - template< class T > struct remove_rvalue_reference< volatile rv& > { typedef T type; }; - template< class T > struct remove_rvalue_reference< const volatile rv& >{ typedef T type; }; -#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -template -typename boost::move_detail::add_rvalue_reference::type declval(); - -} -// Ideas from Boost.Move review, Jeffrey Lee Hellrung: -// -//- TypeTraits metafunctions is_lvalue_reference, add_lvalue_reference, and remove_lvalue_reference ? -// Perhaps add_reference and remove_reference can be modified so that they behave wrt emulated rvalue -// references the same as wrt real rvalue references, i.e., add_reference< rv& > -> T& rather than -// rv& (since T&& & -> T&). -// -//- Add'l TypeTraits has_[trivial_]move_{constructor,assign}...? -// -//- An as_lvalue(T& x) function, which amounts to an identity operation in C++0x, but strips emulated -// rvalue references in C++03. This may be necessary to prevent "accidental moves". - -} //namespace boost { - -#if defined BOOST_MSVC - #pragma warning (pop) - #ifdef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE - #undef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE - #undef _CRT_SECURE_NO_DEPRECATE - #endif - - #ifdef BOOST_INTERPROCESS_SCL_SECURE_NO_WARNINGS - #undef BOOST_INTERPROCESS_SCL_SECURE_NO_WARNINGS - #undef _SCL_SECURE_NO_WARNINGS - #endif -#endif +#include +#include +#include +#include +#include +#include #endif //#ifndef BOOST_MOVE_MOVE_HPP diff --git a/include/boost/move/traits.hpp b/include/boost/move/traits.hpp new file mode 100644 index 0000000..e5c8444 --- /dev/null +++ b/include/boost/move/traits.hpp @@ -0,0 +1,142 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2009-2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +//! \file + +#ifndef BOOST_MOVE_MOVE_TRAITS_HPP +#define BOOST_MOVE_MOVE_TRAITS_HPP + +#include +#include +#include + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +#include +#endif + +namespace boost { + +//! If this trait yields to true +//! (has_trivial_destructor_after_move <T>::value == true) +//! means that if T is used as argument of a move construction/assignment, +//! there is no need to call T's destructor. +//! This optimization tipically is used to improve containers' performance. +//! +//! By default this trait is true if the type has trivial destructor, +//! every class should specialize this trait if it wants to improve performance +//! when inserted in containers. +template +struct has_trivial_destructor_after_move + : ::boost::has_trivial_destructor +{}; + +//! By default this traits returns false. 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 +{}; + +namespace move_detail { + +// Code from Jeffrey Lee Hellrung, many thanks + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template< class T> struct forward_type { typedef T type; }; +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template< class T> + struct forward_type + { typedef const T &type; }; + + template< class T> + struct forward_type< boost::rv > + { typedef T type; }; +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + +template< class T > struct is_rvalue_reference : ::boost::move_detail::integral_constant { }; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template< class T > struct is_rvalue_reference< T&& > : ::boost::move_detail::integral_constant { }; +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template< class T > struct is_rvalue_reference< boost::rv& > + : ::boost::move_detail::integral_constant + {}; + + template< class T > struct is_rvalue_reference< const boost::rv& > + : ::boost::move_detail::integral_constant + {}; +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template< class T > struct add_rvalue_reference { typedef T&& type; }; +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + namespace detail_add_rvalue_reference + { + template< class T + , bool emulation = ::boost::has_move_emulation_enabled::value + , bool rv = ::boost::move_detail::is_rv::value > + struct add_rvalue_reference_impl { typedef T type; }; + + template< class T, bool emulation> + struct add_rvalue_reference_impl< T, emulation, true > { typedef T & type; }; + + template< class T, bool rv > + struct add_rvalue_reference_impl< T, true, rv > { typedef ::boost::rv& type; }; + } // namespace detail_add_rvalue_reference + + template< class T > + struct add_rvalue_reference + : detail_add_rvalue_reference::add_rvalue_reference_impl + { }; + + template< class T > + struct add_rvalue_reference + { typedef T & type; }; + +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + +template< class T > struct remove_rvalue_reference { typedef T type; }; + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template< class T > struct remove_rvalue_reference< T&& > { typedef T type; }; +#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + template< class T > struct remove_rvalue_reference< rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< volatile rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const volatile rv > { typedef T type; }; + template< class T > struct remove_rvalue_reference< rv& > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const rv& > { typedef T type; }; + template< class T > struct remove_rvalue_reference< volatile rv& > { typedef T type; }; + template< class T > struct remove_rvalue_reference< const volatile rv& >{ typedef T type; }; +#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + +template +typename boost::move_detail::add_rvalue_reference::type declval(); + +} //move_detail { + +// Ideas from Boost.Move review, Jeffrey Lee Hellrung: +// +//- TypeTraits metafunctions is_lvalue_reference, add_lvalue_reference, and remove_lvalue_reference ? +// Perhaps add_reference and remove_reference can be modified so that they behave wrt emulated rvalue +// references the same as wrt real rvalue references, i.e., add_reference< rv& > -> T& rather than +// rv& (since T&& & -> T&). +// +//- Add'l TypeTraits has_[trivial_]move_{constructor,assign}...? +// +//- An as_lvalue(T& x) function, which amounts to an identity operation in C++0x, but strips emulated +// rvalue references in C++03. This may be necessary to prevent "accidental moves". + + +} //namespace boost { + +#include + +#endif //#ifndef BOOST_MOVE_MOVE_TRAITS_HPP diff --git a/include/boost/move/utility.hpp b/include/boost/move/utility.hpp new file mode 100644 index 0000000..fb2ec69 --- /dev/null +++ b/include/boost/move/utility.hpp @@ -0,0 +1,194 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2012-2012. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/move for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +//! \file + +#ifndef BOOST_MOVE_MOVE_UTILITY_HPP +#define BOOST_MOVE_MOVE_UTILITY_HPP + +#include +#include +#include + +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) + + namespace boost { + + template + struct enable_move_utility_emulation + { + static const bool value = true; + }; + + ////////////////////////////////////////////////////////////////////////////// + // + // move() + // + ////////////////////////////////////////////////////////////////////////////// + + template + inline typename ::boost::move_detail::enable_if_c + < enable_move_utility_emulation::value && !has_move_emulation_enabled::value, T&>::type + move(T& x) + { + return x; + } + + template + inline typename ::boost::move_detail::enable_if_c + < enable_move_utility_emulation::value && has_move_emulation_enabled::value, rv&>::type + move(T& x) + { + return *static_cast* >(::boost::move_detail::addressof(x)); + } + + template + inline typename ::boost::move_detail::enable_if_c + < enable_move_utility_emulation::value && has_move_emulation_enabled::value, rv&>::type + move(rv& x) + { + return x; + } + + ////////////////////////////////////////////////////////////////////////////// + // + // forward() + // + ////////////////////////////////////////////////////////////////////////////// + + 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) + { + return const_cast(x); + } + + 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) + { + return x; + } + + } //namespace boost + +#else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) + + #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) + #include + + namespace boost{ + + using ::std::move; + using ::std::forward; + + } //namespace boost + + #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE + + #include + + namespace boost { + + //! This trait's internal boolean `value` is false in compilers with rvalue references + //! and true in compilers without rvalue references. + //! + //! A user can specialize this trait for a type T to false to SFINAE out `move` and `forward` + //! so that the user can define a different move emulation for that type in namespace boost + //! (e.g. another Boost library for its types) and avoid any overload ambiguity. + template + struct enable_move_utility_emulation + { + static const bool value = false; + }; + + ////////////////////////////////////////////////////////////////////////////// + // + // move + // + ////////////////////////////////////////////////////////////////////////////// + + #if defined(BOOST_MOVE_DOXYGEN_INVOKED) + //! This function provides a way to convert a reference into a rvalue reference + //! 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); + + #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) + { return t; } + + #else //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + + template + inline typename remove_reference::type && move(T&& t) + { return static_cast::type &&>(t); } + + #endif //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + + ////////////////////////////////////////////////////////////////////////////// + // + // forward + // + ////////////////////////////////////////////////////////////////////////////// + + + #if defined(BOOST_MOVE_DOXYGEN_INVOKED) + //! This function provides limited form of forwarding that is usually enough for + //! in-place construction and avoids the exponential overloading for + //! achieve the limited forwarding in C++03. + //! + //! For compilers with rvalue references this function provides perfect forwarding. + //! + //! Otherwise: + //! * If input_reference binds to const ::boost::rv & then it output_reference is + //! ::boost::rv & + //! + //! * Else, output_reference is equal to input_reference. + template output_reference forward(input_reference); + #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) + { return t; } + + #else //Old move + + //Implementation #5 from N2951, thanks to Howard Hinnant + + template + inline T&& forward(U&& t + , typename ::boost::move_detail::enable_if_c< + 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*/) + { return static_cast(t); } + + #endif //BOOST_MOVE_DOXYGEN_INVOKED + + } //namespace boost { + + #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE) + +#endif //BOOST_NO_CXX11_RVALUE_REFERENCES + +#include + +#endif //#ifndef BOOST_MOVE_MOVE_UTILITY_HPP From fb70dadc596aced9840d6934f0ec0a6b7506d4e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 24 Nov 2012 21:03:23 +0000 Subject: [PATCH 26/26] * Better header segregation (bug [@https://svn.boost.org/trac/boost/ticket/6524 #6524]). * Small documentation fixes * Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros. [SVN r81515] --- doc/Jamfile.v2 | 2 +- doc/move.qbk | 15 ++++- example/copymovable.hpp | 6 +- example/doc_clone_ptr.cpp | 5 +- example/doc_construct_forward.cpp | 6 +- example/doc_file_descriptor.cpp | 8 ++- example/doc_how_works.cpp | 9 ++- example/doc_move_algorithms.cpp | 5 ++ example/doc_move_inserter.cpp | 12 ++-- example/doc_move_iterator.cpp | 4 +- example/movable.hpp | 7 +- proj/vc7ide/Move.sln | 106 +++--------------------------- test/back_move_inserter.cpp | 5 +- test/construct_forward.cpp | 24 +++---- test/conversion_test.cpp | 20 +++--- test/copy_elision_test.cpp | 13 ++-- test/copy_move_optimization.cpp | 4 +- test/move.cpp | 8 ++- test/move_algorithm.cpp | 5 +- test/move_iterator.cpp | 55 +--------------- 20 files changed, 122 insertions(+), 197 deletions(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 55c1702..f970d61 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -13,7 +13,7 @@ import quickbook ; doxygen autodoc : - [ glob ../../../boost/move/move.hpp ] + [ glob ../../../boost/move/*.hpp ] : HIDE_UNDOC_MEMBERS=YES HIDE_UNDOC_MEMBERS=YES diff --git a/doc/move.qbk b/doc/move.qbk index 7224176..e4591c1 100644 --- a/doc/move.qbk +++ b/doc/move.qbk @@ -7,7 +7,7 @@ [library Boost.Move [quickbook 1.5] [authors [Gaztanaga, Ion]] - [copyright 2008-2010 Ion Gaztanaga] + [copyright 2008-2012 Ion Gaztanaga] [id move] [dirname move] [purpose Move semantics] @@ -318,7 +318,7 @@ This library makes this emulation easy with the help of `BOOST_FWD_REF` and [import ../example/doc_construct_forward.cpp] [construct_forward_example] -Constructor forwarding comes handful to implement placement insertion in containers with +Constructor forwarding comes in handy to implement placement insertion in containers with just N overloads if the implementor accepts the limitations of this type of forwarding for C++03 compilers. In compilers with rvalue references perfect forwarding is achieved. @@ -778,7 +778,7 @@ presence of three overloads and the conversion operators in C++03 compilers: [section:thanks_to Thanks and credits] Thanks to all that developed ideas for move emulation: the first emulation was based on Howard Hinnant -emulation code for `unique_ptr`, David Abrahams suggested the use of `class rv` class, +emulation code for `unique_ptr`, David Abrahams suggested the use of `class rv`, and Klaus Triendl discovered how to bind const rlvalues using `class rv`. Many thanks to all boosters that have tested, reviewed and improved the library. @@ -787,6 +787,15 @@ Many thanks to all boosters that have tested, reviewed and improved the library. [section:release_notes Release Notes] +[section:release_notes_boost_1_53_00 Boost 1.53 Release] + +* Better header segregation (bug + [@https://svn.boost.org/trac/boost/ticket/6524 #6524]). +* Small documentation fixes +* Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros. + +[endsect] + [section:release_notes_boost_1_51_00 Boost 1.51 Release] * Fixed bugs diff --git a/example/copymovable.hpp b/example/copymovable.hpp index c3b4793..cb2c050 100644 --- a/example/copymovable.hpp +++ b/example/copymovable.hpp @@ -11,9 +11,11 @@ #ifndef BOOST_MOVE_TEST_COPYMOVABLE_HPP #define BOOST_MOVE_TEST_COPYMOVABLE_HPP +#include + //[movable_definition //header file "copy_movable.hpp" -#include +#include //A copy_movable class class copy_movable @@ -43,4 +45,6 @@ class copy_movable //] +#include + #endif //BOOST_MOVE_TEST_COPYMOVABLE_HPP diff --git a/example/doc_clone_ptr.cpp b/example/doc_clone_ptr.cpp index 56c0816..976b142 100644 --- a/example/doc_clone_ptr.cpp +++ b/example/doc_clone_ptr.cpp @@ -8,7 +8,8 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// -#include +#include +#include //[clone_ptr_base_derived class Base @@ -152,3 +153,5 @@ int main() //] return 0; } + +#include diff --git a/example/doc_construct_forward.cpp b/example/doc_construct_forward.cpp index 07be958..4eee536 100644 --- a/example/doc_construct_forward.cpp +++ b/example/doc_construct_forward.cpp @@ -9,8 +9,10 @@ // ////////////////////////////////////////////////////////////////////////////// +#include + //[construct_forward_example -#include +#include #include class copyable_only_tester @@ -103,3 +105,5 @@ int main() return 0; } //] + +#include diff --git a/example/doc_file_descriptor.cpp b/example/doc_file_descriptor.cpp index 6d008d3..e4e6ba3 100644 --- a/example/doc_file_descriptor.cpp +++ b/example/doc_file_descriptor.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2008-2009. +// (C) Copyright Ion Gaztanaga 2008-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -9,9 +9,11 @@ // ////////////////////////////////////////////////////////////////////////////// +#include + //[file_descriptor_def -#include +#include #include class file_descriptor @@ -85,3 +87,5 @@ int main() return 0; } //] + +#include diff --git a/example/doc_how_works.cpp b/example/doc_how_works.cpp index e2116c5..ef28be4 100644 --- a/example/doc_how_works.cpp +++ b/example/doc_how_works.cpp @@ -11,7 +11,7 @@ #include -#if !defined(BOOST_NO_RVALUE_REFERENCES) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) int main() { @@ -20,8 +20,10 @@ int main() #else +#include + //[how_works_example -#include +#include #include class sink_tester @@ -56,5 +58,6 @@ int main() } //] -#endif +#include +#endif diff --git a/example/doc_move_algorithms.cpp b/example/doc_move_algorithms.cpp index c9ca065..6fe487a 100644 --- a/example/doc_move_algorithms.cpp +++ b/example/doc_move_algorithms.cpp @@ -9,8 +9,11 @@ // ////////////////////////////////////////////////////////////////////////////// +#include + //[move_algorithms_example #include "movable.hpp" +#include #include #include @@ -39,3 +42,5 @@ int main() return 0; } //] + +#include diff --git a/example/doc_move_inserter.cpp b/example/doc_move_inserter.cpp index 1e0b9dc..c715412 100644 --- a/example/doc_move_inserter.cpp +++ b/example/doc_move_inserter.cpp @@ -9,10 +9,13 @@ // ////////////////////////////////////////////////////////////////////////////// +#include + //[move_inserter_example #include #include "movable.hpp" #include +#include using namespace ::boost::container; @@ -27,10 +30,9 @@ void test_move_inserter(list_t &l2, MoveInsertIterator mit) assert(!l.begin()->moved()); l2.clear(); - //Move construct - for(l_iterator itbeg = l.begin(), itend = l.end(); itbeg != itend; ++itbeg){ - *mit = *itbeg; - } + //Move insert into l2 containers + std::copy(l.begin(), l.end(), mit); + //Check size and status assert(l2.size() == l.size()); assert(l.begin()->moved()); @@ -46,3 +48,5 @@ int main() return 0; } //] + +#include diff --git a/example/doc_move_iterator.cpp b/example/doc_move_iterator.cpp index 0e7cc51..86d3893 100644 --- a/example/doc_move_iterator.cpp +++ b/example/doc_move_iterator.cpp @@ -8,7 +8,7 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// - +#include //[move_iterator_example #include #include "movable.hpp" @@ -37,3 +37,5 @@ int main() return 0; } //] + +#include diff --git a/example/movable.hpp b/example/movable.hpp index 89b4397..07912dd 100644 --- a/example/movable.hpp +++ b/example/movable.hpp @@ -11,9 +11,12 @@ #ifndef BOOST_MOVE_TEST_MOVABLE_HPP #define BOOST_MOVE_TEST_MOVABLE_HPP +#include + //[movable_definition //header file "movable.hpp" -#include +#include +#include //A movable class class movable @@ -46,4 +49,6 @@ struct has_nothrow_move } //namespace boost{ //] +#include + #endif //BOOST_MOVE_TEST_MOVABLE_HPP diff --git a/proj/vc7ide/Move.sln b/proj/vc7ide/Move.sln index 894918a..4e2b273 100644 --- a/proj/vc7ide/Move.sln +++ b/proj/vc7ide/Move.sln @@ -1,52 +1,4 @@ Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "construct_forward_test", "construct_forward_test.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "move_iterator_test", "move_iterator_test.vcproj", "{C8AD2618-79EB-8612-42FE-2A3AC9667A13}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "move_test", "move_test.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "move_algorithm_test", "move_algorithm.vcproj", "{C8AD2618-79EB-8612-42FE-2A3AC9667A13}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_clone_ptr", "doc_clone_ptr.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_file_descriptor", "doc_file_descriptor.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_move_iterator", "doc_move_iterator.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_move_inserter", "doc_move_inserter.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_move_algorithms", "doc_move_algorithms.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_construct_forward", "doc_construct_forward.vcproj", "{CD57C283-1862-42FE-BF87-B96D3A2A7912}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "back_move_inserter_test", "back_move_inserter_test.vcproj", "{C8AD2618-79EB-8612-42FE-2A3AC9667A13}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "copy_move_optimization_test", "copy_move_optimization.vcproj", "{C8AD2618-79EB-8612-42FE-2A3AC9667A13}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "copy_elision_test_test", "copy_elision_test.vcproj", "{C8AD2618-79EB-8612-42FE-2A3AC9667A13}" ProjectSection(ProjectDependencies) = postProject EndProjectSection @@ -67,54 +19,6 @@ Global GlobalSection(ProjectDependencies) = postSolution EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.ActiveCfg = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.Build.0 = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.ActiveCfg = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.Build.0 = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.ActiveCfg = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.Build.0 = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.ActiveCfg = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.Build.0 = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.ActiveCfg = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32 - {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.ActiveCfg = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.Build.0 = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.ActiveCfg = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.Build.0 = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.ActiveCfg = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.Build.0 = Debug|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.ActiveCfg = Release|Win32 - {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.Build.0 = Release|Win32 {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.ActiveCfg = Debug|Win32 {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Debug.Build.0 = Debug|Win32 {C8AD2618-79EB-8612-42FE-2A3AC9667A13}.Release.ActiveCfg = Release|Win32 @@ -129,10 +33,18 @@ Global {CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionItems) = postSolution + ..\..\..\..\boost\move\algorithm.hpp = ..\..\..\..\boost\move\algorithm.hpp + ..\..\..\..\boost\move\detail\config_begin.hpp = ..\..\..\..\boost\move\detail\config_begin.hpp + ..\..\..\..\boost\move\detail\config_end.hpp = ..\..\..\..\boost\move\detail\config_end.hpp + ..\..\..\..\boost\move\core.hpp = ..\..\..\..\boost\move\core.hpp + ..\..\..\..\boost\move\iterator.hpp = ..\..\..\..\boost\move\iterator.hpp ..\..\doc\Jamfile.v2 = ..\..\doc\Jamfile.v2 + ..\..\..\..\boost\move\detail\meta_utils.hpp = ..\..\..\..\boost\move\detail\meta_utils.hpp ..\..\..\..\boost\move\move.hpp = ..\..\..\..\boost\move\move.hpp ..\..\doc\move.qbk = ..\..\doc\move.qbk - ..\..\..\..\boost\move\move_helpers.hpp = ..\..\..\..\boost\move\move_helpers.hpp + ..\..\..\..\boost\move\detail\move_helpers.hpp = ..\..\..\..\boost\move\detail\move_helpers.hpp + ..\..\..\..\boost\move\traits.hpp = ..\..\..\..\boost\move\traits.hpp + ..\..\..\..\boost\move\utility.hpp = ..\..\..\..\boost\move\utility.hpp EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/test/back_move_inserter.cpp b/test/back_move_inserter.cpp index 1505125..eeddd6b 100644 --- a/test/back_move_inserter.cpp +++ b/test/back_move_inserter.cpp @@ -8,7 +8,8 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// -#include +#include +#include #include #include #include @@ -72,3 +73,5 @@ int main() } return 0; } + +#include diff --git a/test/construct_forward.cpp b/test/construct_forward.cpp index bf4c526..6922d82 100644 --- a/test/construct_forward.cpp +++ b/test/construct_forward.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009-2011. +// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -8,8 +8,8 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// - -#include +#include +#include #include #include "../example/movable.hpp" #include "../example/copymovable.hpp" @@ -24,36 +24,36 @@ class non_movable template void catch_test(BOOST_RV_REF(MaybeRvalue) x - #ifdef BOOST_NO_RVALUE_REFERENCES + #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES ,typename ::boost::enable_if< ::boost::has_move_emulation_enabled >::type* = 0 - #endif //BOOST_NO_RVALUE_REFERENCES + #endif //BOOST_NO_CXX11_RVALUE_REFERENCES ) { (void)x;} template void catch_test(BOOST_COPY_ASSIGN_REF(MaybeRvalue) x - #ifdef BOOST_NO_RVALUE_REFERENCES + #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES ,typename ::boost::enable_if< ::boost::has_move_emulation_enabled >::type* = 0 - #endif //BOOST_NO_RVALUE_REFERENCES + #endif //BOOST_NO_CXX11_RVALUE_REFERENCES ) { (void)x;} template void catch_test(MaybeRvalue &x - #ifdef BOOST_NO_RVALUE_REFERENCES + #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES ,typename ::boost::enable_if< ::boost::has_move_emulation_enabled >::type* = 0 - #endif //BOOST_NO_RVALUE_REFERENCES + #endif //BOOST_NO_CXX11_RVALUE_REFERENCES ) { (void)x;} - #ifdef BOOST_NO_RVALUE_REFERENCES + #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES template void catch_test(const MaybeRvalue& x ,typename ::boost::disable_if< ::boost::has_move_emulation_enabled >::type* = 0 ) { (void)x;} - #endif //BOOST_NO_RVALUE_REFERENCES + #endif //BOOST_NO_CXX11_RVALUE_REFERENCES movable create_movable() { return movable(); } @@ -113,3 +113,5 @@ int main() forward_test(); return 0; } + +#include diff --git a/test/conversion_test.cpp b/test/conversion_test.cpp index 99157c1..5c973d7 100644 --- a/test/conversion_test.cpp +++ b/test/conversion_test.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2010-2011. +// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2010-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -8,12 +8,14 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// -#include +#include +#include #include #include #include -#include +#include +#include enum ConstructionType { Copied, Moved, Other }; @@ -105,11 +107,11 @@ class container template void priv_push_back(BOOST_MOVE_CATCH_FWD(U) x) - { new (&storage_) T(::boost::forward(x)); } + { ::new (&storage_) T(::boost::forward(x)); } template iterator priv_insert(const_iterator, BOOST_MOVE_CATCH_FWD(U) x) - { new (&storage_) T(::boost::forward(x)); return 0; } + { ::new (&storage_) T(::boost::forward(x)); return 0; } }; @@ -292,8 +294,10 @@ int main() return 0; } +#include + /* -#include +#include #include #include #include @@ -366,7 +370,7 @@ class conversion_target_movable struct not_a_type; -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #define BOOST_MOVE_CATCH_CONST(U) \ typename ::boost::mpl::if_< ::boost::is_class, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type #define BOOST_MOVE_CATCH_RVALUE(U)\ @@ -470,7 +474,7 @@ class container { return priv_push_back(::boost::move(x)); } //Tricks for C++03 - #if defined(BOOST_NO_RVALUE_REFERENCES) + #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) void push_back(T &x) { priv_push_back(const_cast(x)); } diff --git a/test/copy_elision_test.cpp b/test/copy_elision_test.cpp index 01bf212..b15ebf2 100644 --- a/test/copy_elision_test.cpp +++ b/test/copy_elision_test.cpp @@ -2,6 +2,7 @@ // Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include #include #ifdef NO_MOVE @@ -11,7 +12,7 @@ # define BOOST_COPYABLE_AND_MOVABLE(X) # define MOVE(x) (x) #else -#include +#include # define MOVE(x) boost::move(x) #endif @@ -91,17 +92,17 @@ unsigned X::instances = 0; struct trace { trace(char const* name) - : name(name) + : m_name(name) { - std::cout << "->: " << name << "\n"; + std::cout << "->: " << m_name << "\n"; } ~trace() { - std::cout << "<-: " << name << "\n"; + std::cout << "<-: " << m_name << "\n"; } - char const* name; + char const* m_name; }; void sink(X a) @@ -168,3 +169,5 @@ int main(int argc, char* argv[]) CHECK_COPIES( X a = ternary( argc != 1000 ), 0, 2, "Return result of ternary operation again" ); return 0; } + +#include diff --git a/test/copy_move_optimization.cpp b/test/copy_move_optimization.cpp index 10a0f20..4702a6f 100644 --- a/test/copy_move_optimization.cpp +++ b/test/copy_move_optimization.cpp @@ -8,7 +8,8 @@ //Optimization: //Since RVO is better than move-construction, //avoid copy constructor overloading. -#include +#include +#include #include bool moved = false; @@ -103,3 +104,4 @@ int main() //1 const rv & constructor: copy constructor //1 T & constructor: copy constructor +#include diff --git a/test/move.cpp b/test/move.cpp index e3e3790..e0e21f1 100644 --- a/test/move.cpp +++ b/test/move.cpp @@ -8,8 +8,8 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// - -#include +#include +#include #include "../example/movable.hpp" #include @@ -64,7 +64,7 @@ movable create_movable() { return movable(); } int main() { - #if defined(BOOST_NO_RVALUE_REFERENCES) + #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)); @@ -112,3 +112,5 @@ int main() return 0; } + +#include diff --git a/test/move_algorithm.cpp b/test/move_algorithm.cpp index 0568f7c..d3944b1 100644 --- a/test/move_algorithm.cpp +++ b/test/move_algorithm.cpp @@ -8,7 +8,8 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// -#include +#include +#include #include #include "../example/movable.hpp" @@ -53,3 +54,5 @@ int main() return 0; } + +#include diff --git a/test/move_iterator.cpp b/test/move_iterator.cpp index 10cc2bd..37c39f3 100644 --- a/test/move_iterator.cpp +++ b/test/move_iterator.cpp @@ -8,8 +8,8 @@ // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// - -#include +#include +#include #include #include "../example/movable.hpp" @@ -52,53 +52,4 @@ int main() return 0; } -/* -#include - - -class copy_movable -{ - BOOST_COPYABLE_AND_MOVABLE(copy_movable) - int value_; - - public: - copy_movable() : value_(1){} - - //Move constructor and assignment - copy_movable(BOOST_RV_REF(copy_movable) m) - { value_ = m.value_; m.value_ = 0; } - - copy_movable(const copy_movable &m) - { value_ = m.value_; } - - copy_movable & operator=(BOOST_RV_REF(copy_movable) m) - { value_ = m.value_; m.value_ = 0; return *this; } - - copy_movable & operator=(BOOST_COPY_ASSIGN_REF(copy_movable) m) - { value_ = m.value_; return *this; } - - bool moved() const //Observer - { return value_ == 0; } -}; - -struct copy_movable_wrapper -{ - copy_movable cm; -}; - -copy_movable produce() -{ return copy_movable(); } - - -int main() -{ - copy_movable cm; - cm = produce(); - - const copy_movable_wrapper cmw; - copy_movable_wrapper cmw2; - cmw2 = cmw; - - return 0; -} -*/ \ No newline at end of file +#include