diff --git a/include/boost/interprocess/offset_ptr.hpp b/include/boost/interprocess/offset_ptr.hpp index 951f774..66d38cc 100644 --- a/include/boost/interprocess/offset_ptr.hpp +++ b/include/boost/interprocess/offset_ptr.hpp @@ -34,7 +34,6 @@ #include //alignment_of, aligned_storage #include #include -#include //!\file //!Describes a smart pointer that stores the offset between this pointer and diff --git a/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp b/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp index 9e5cfa2..585b995 100755 --- a/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp @@ -32,6 +32,7 @@ #include #include #include +#include #include // for std::basic_ostream @@ -72,6 +73,8 @@ class intrusive_ptr typedef pointer this_type::*unspecified_bool_type; #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED + BOOST_COPYABLE_AND_MOVABLE(intrusive_ptr) + public: //!Constructor. Initializes internal pointer to 0. //!Does not throw @@ -96,14 +99,12 @@ class intrusive_ptr if(m_ptr != 0) intrusive_ptr_add_ref(ipcdetail::to_raw_pointer(m_ptr)); } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES //!Move constructor. Moves the internal pointer. Does not throw - intrusive_ptr(intrusive_ptr&& rhs) BOOST_NOEXCEPT + intrusive_ptr(BOOST_RV_REF(intrusive_ptr) rhs) BOOST_NOEXCEPT : m_ptr(rhs.m_ptr) { rhs.m_ptr = 0; } -#endif //!Constructor from related. Copies the internal pointer and if "p" is not //!zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw @@ -121,23 +122,20 @@ class intrusive_ptr //!Assignment operator. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw - intrusive_ptr & operator=(intrusive_ptr const & rhs) BOOST_NOEXCEPT + intrusive_ptr & operator=(BOOST_COPY_ASSIGN_REF(intrusive_ptr) rhs) BOOST_NOEXCEPT { this_type(rhs).swap(*this); return *this; } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES //!Move Assignment operator //!Does not throw - intrusive_ptr & operator=(intrusive_ptr&& rhs) BOOST_NOEXCEPT + intrusive_ptr & operator=(BOOST_RV_REF(intrusive_ptr) rhs) BOOST_NOEXCEPT { rhs.swap(*this); rhs.reset(); return *this; } -#endif //!Assignment from related. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw diff --git a/test/intrusive_ptr_test.cpp b/test/intrusive_ptr_test.cpp index ce79f8e..f3e4812 100644 --- a/test/intrusive_ptr_test.cpp +++ b/test/intrusive_ptr_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include typedef boost::interprocess::offset_ptr VP; @@ -195,7 +196,6 @@ void copy_constructor() } } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES void move_constructor() { { @@ -204,26 +204,22 @@ void move_constructor() boost::interprocess::intrusive_ptr px(x); BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); - static_assert(std::is_nothrow_move_constructible< boost::interprocess::intrusive_ptr >::value, "test instrusive_ptr is nothrow move constructible"); + //static_assert(std::is_nothrow_move_constructible< boost::interprocess::intrusive_ptr >::value, "test instrusive_ptr is nothrow move constructible"); - boost::interprocess::intrusive_ptr px2(std::move(px)); + boost::interprocess::intrusive_ptr px2(boost::move(px)); BOOST_TEST(px2.get() == x); - BOOST_TEST(px.get() == nullptr); + BOOST_TEST(!px.get()); BOOST_TEST(px2->use_count() == 1); BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); } } -#endif void test() { default_constructor(); pointer_constructor(); copy_constructor(); - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - move_constructor(); -#endif + move_constructor(); } } // namespace n_constructors @@ -253,7 +249,6 @@ void copy_assignment() { } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES void move_assignment() { { @@ -263,17 +258,16 @@ void move_assignment() BOOST_TEST(px->use_count() == 1); BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); - static_assert(std::is_nothrow_move_assignable< boost::interprocess::intrusive_ptr >::value, "test if nothrow move assignable "); + //static_assert(std::is_nothrow_move_assignable< boost::interprocess::intrusive_ptr >::value, "test if nothrow move assignable "); boost::interprocess::intrusive_ptr px2; - px2 = std::move(px); + px2 = boost::move(px); BOOST_TEST(px2.get() == x); - BOOST_TEST(px.get() == nullptr); + BOOST_TEST(!px.get()); BOOST_TEST(px2->use_count() == 1); BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); } } -#endif void conversion_assignment() { @@ -288,10 +282,7 @@ void test() copy_assignment(); conversion_assignment(); pointer_assignment(); - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES move_assignment(); -#endif } } // namespace n_assignment