mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 14:28:30 +00:00
Fix shared_ptr::owner_before (#1274)
This method is supposed to give equivalence iff two shared pointers both own the same object, even if they point to different addresses. We can't control the exact order of the control blocks in memory, so the test can only check that this equivalence/non-equivalence relationship holds, and this is in fact all that it should check.
This commit is contained in:
parent
48b703b3f6
commit
ae57fa2c4e
2 changed files with 8 additions and 11 deletions
|
@ -335,11 +335,10 @@ class shared_ptr
|
|||
return p;
|
||||
}
|
||||
|
||||
#if 0 // TODO(mrdomino): find a different way
|
||||
template<typename U>
|
||||
bool owner_before(const shared_ptr<U>& r) const noexcept
|
||||
{
|
||||
return p < r.p;
|
||||
return rc < r.rc;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
|
@ -347,7 +346,6 @@ class shared_ptr
|
|||
{
|
||||
return !r.owner_before(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
template<typename U>
|
||||
|
@ -422,13 +420,13 @@ class weak_ptr
|
|||
template<typename U>
|
||||
bool owner_before(const weak_ptr<U>& r) const noexcept
|
||||
{
|
||||
return p < r.p;
|
||||
return rc < r.rc;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
bool owner_before(const shared_ptr<U>& r) const noexcept
|
||||
{
|
||||
return p < r.p;
|
||||
return rc < r.rc;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue