mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 16:30:29 +00:00
Minor cleanup
Put a noexcept annotation on drop_shared (since dispose is also noexcept for now) and simplify reset, fixing a bug in weak_ptr::swap.
This commit is contained in:
parent
f138d80c29
commit
72a9984055
1 changed files with 4 additions and 10 deletions
|
@ -72,7 +72,7 @@ class shared_ref
|
|||
incref(&shared);
|
||||
}
|
||||
|
||||
void drop_shared()
|
||||
void drop_shared() noexcept
|
||||
{
|
||||
if (decref(&shared)) {
|
||||
dispose();
|
||||
|
@ -281,11 +281,7 @@ class shared_ptr
|
|||
|
||||
void reset() noexcept
|
||||
{
|
||||
if (rc) {
|
||||
rc->drop_shared();
|
||||
}
|
||||
p = nullptr;
|
||||
rc = nullptr;
|
||||
shared_ptr().swap(*this);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
|
@ -398,14 +394,12 @@ class weak_ptr
|
|||
|
||||
void reset() noexcept
|
||||
{
|
||||
if (rc)
|
||||
rc->drop_weak();
|
||||
p = nullptr;
|
||||
rc = nullptr;
|
||||
weak_ptr().swap(*this);
|
||||
}
|
||||
|
||||
void swap(weak_ptr& r) noexcept
|
||||
{
|
||||
using ctl::swap;
|
||||
swap(p, r.p);
|
||||
swap(rc, r.rc);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue