mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-30 12:47:28 +02:00
Add mixed shared_count/weak_count operator< overloads to avoid refcount manipulation
This commit is contained in:
@ -494,11 +494,13 @@ public:
|
||||
return a.pi_ == b.pi_;
|
||||
}
|
||||
|
||||
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 std::less<sp_counted_base *>()( a.pi_, b.pi_ );
|
||||
return std::less<sp_counted_base *>()( pi_, r.pi_ );
|
||||
}
|
||||
|
||||
bool operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT;
|
||||
|
||||
void * get_deleter( sp_typeinfo_ const & ti ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_? pi_->get_deleter( ti ): 0;
|
||||
@ -625,9 +627,14 @@ public:
|
||||
return a.pi_ == b.pi_;
|
||||
}
|
||||
|
||||
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 std::less<sp_counted_base *>()(a.pi_, b.pi_);
|
||||
return std::less<sp_counted_base *>()( pi_, r.pi_ );
|
||||
}
|
||||
|
||||
bool operator<( shared_count const & r ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return std::less<sp_counted_base *>()( pi_, r.pi_ );
|
||||
}
|
||||
};
|
||||
|
||||
@ -653,6 +660,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 std::less<sp_counted_base *>()( pi_, r.pi_ );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
Reference in New Issue
Block a user