From 2122c7753c01265990419029eb1de901cc8d77d9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 22 Apr 2019 02:17:28 +0300 Subject: [PATCH] Avoid memcpy over a spinlock, because g++ 8 warns --- include/boost/smart_ptr/atomic_shared_ptr.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/boost/smart_ptr/atomic_shared_ptr.hpp b/include/boost/smart_ptr/atomic_shared_ptr.hpp index 7c48507..b863100 100644 --- a/include/boost/smart_ptr/atomic_shared_ptr.hpp +++ b/include/boost/smart_ptr/atomic_shared_ptr.hpp @@ -63,6 +63,11 @@ public: { } + atomic_shared_ptr( shared_ptr p ) BOOST_SP_NOEXCEPT + : p_( std::move( p ) ), l_ BOOST_DETAIL_SPINLOCK_INIT + { + } + #else atomic_shared_ptr() BOOST_SP_NOEXCEPT @@ -71,8 +76,6 @@ public: std::memcpy( &l_, &init, sizeof( init ) ); } -#endif - atomic_shared_ptr( shared_ptr p ) BOOST_SP_NOEXCEPT #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) : p_( std::move( p ) ) @@ -84,6 +87,8 @@ public: std::memcpy( &l_, &init, sizeof( init ) ); } +#endif + atomic_shared_ptr& operator=( shared_ptr r ) BOOST_SP_NOEXCEPT { boost::detail::spinlock::scoped_lock lock( l_ );