Add mixed shared_count/weak_count operator== overloads to avoid refcount manipulation

This commit is contained in:
Peter Dimov
2020-05-31 22:07:36 +03:00
parent 58915ca2fe
commit 4b724ab3f8

View File

@ -489,11 +489,13 @@ public:
return pi_ == 0;
}
friend inline bool operator==(shared_count const & a, shared_count const & b) BOOST_SP_NOEXCEPT
bool operator==( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return a.pi_ == b.pi_;
return pi_ == r.pi_;
}
bool operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT;
bool operator<( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
@ -622,9 +624,14 @@ public:
return pi_ == 0;
}
friend inline bool operator==(weak_count const & a, weak_count const & b) BOOST_SP_NOEXCEPT
bool operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return a.pi_ == b.pi_;
return pi_ == r.pi_;
}
bool operator==( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
bool operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT
@ -660,6 +667,11 @@ inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ) BOOST_
}
}
inline bool shared_count::operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
inline bool shared_count::operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );