mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 08:20:28 +00:00
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:
parent
acbf10c702
commit
74e5e85467
1 changed files with 6 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue