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:
Steven Dee (Jōshin) 2024-08-30 08:42:50 -07:00
parent f138d80c29
commit 72a9984055
No known key found for this signature in database

View file

@ -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);
}