Clean up reset to match spec

Remove the variants from the T[] specialization. Also follow the spec on
the order of operations in reset, which may matter if we are deleting an
object that has a reference to the unique_ptr that is being reset. (?)
This commit is contained in:
Steven Dee (Jōshin) 2024-06-19 06:52:09 -07:00
parent acbf10c702
commit 74e5e85467
No known key found for this signature in database

View file

@ -70,7 +70,8 @@ struct unique_ptr
~unique_ptr() /* noexcept */
{
reset();
if (p)
d(p);
}
unique_ptr& operator=(unique_ptr r) noexcept
@ -86,19 +87,12 @@ struct unique_ptr
return r;
}
void reset(const nullptr_t = nullptr) noexcept
void reset(const pointer p2 = pointer()) noexcept
{
if (p)
d(p);
p = nullptr;
}
void reset(auto* const p2)
{
if (p) {
d(p);
}
const pointer r = p;
p = p2;
if (r)
d(r);
}
void swap(unique_ptr& r) noexcept