mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-08-02 22:24:26 +02:00
Change atomic operations to take an arbitrary MemoryOrder type, to fix test breakage caused by transition to scoped enum in Boost.Atomic, tracking C++20
This commit is contained in:
@@ -97,7 +97,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<T> load( int = 0 ) const BOOST_SP_NOEXCEPT
|
||||
shared_ptr<T> load() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
return p_;
|
||||
}
|
||||
|
||||
template<class M> shared_ptr<T> load( M ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
return p_;
|
||||
@@ -109,13 +115,19 @@ public:
|
||||
return p_;
|
||||
}
|
||||
|
||||
void store( shared_ptr<T> r, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
void store( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
p_.swap( r );
|
||||
}
|
||||
|
||||
shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> void store( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
p_.swap( r );
|
||||
}
|
||||
|
||||
shared_ptr<T> exchange( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
@@ -133,44 +145,82 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
template<class M> shared_ptr<T> exchange( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
p_.swap( r );
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
return std::move( r );
|
||||
|
||||
#else
|
||||
|
||||
return r;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
@@ -1080,7 +1080,7 @@ template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) BOOST_SP_
|
||||
return *p;
|
||||
}
|
||||
|
||||
template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return atomic_load( p );
|
||||
}
|
||||
@@ -1091,7 +1091,7 @@ template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) BOOST_
|
||||
p->swap( r );
|
||||
}
|
||||
|
||||
template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
atomic_store( p, r ); // std::move( r )
|
||||
}
|
||||
@@ -1107,7 +1107,7 @@ template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T
|
||||
return r; // return std::move( r )
|
||||
}
|
||||
|
||||
template<class T> shared_ptr<T> inline atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> shared_ptr<T> inline atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return atomic_exchange( p, r ); // std::move( r )
|
||||
}
|
||||
@@ -1137,7 +1137,7 @@ template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T>
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ M, /*memory_order failure*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return atomic_compare_exchange( p, v, w ); // std::move( w )
|
||||
}
|
||||
|
Reference in New Issue
Block a user