mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-05 17:30:27 +00:00
Make more things constexpr
This commit is contained in:
parent
74e5e85467
commit
0b41210c1f
1 changed files with 9 additions and 9 deletions
|
@ -68,26 +68,26 @@ struct unique_ptr
|
||||||
|
|
||||||
unique_ptr(const unique_ptr&) = delete;
|
unique_ptr(const unique_ptr&) = delete;
|
||||||
|
|
||||||
~unique_ptr() /* noexcept */
|
constexpr ~unique_ptr() /* noexcept */
|
||||||
{
|
{
|
||||||
if (p)
|
if (p)
|
||||||
d(p);
|
d(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr& operator=(unique_ptr r) noexcept
|
constexpr unique_ptr& operator=(unique_ptr r) noexcept
|
||||||
{
|
{
|
||||||
swap(r);
|
swap(r);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer release() noexcept
|
constexpr pointer release() noexcept
|
||||||
{
|
{
|
||||||
pointer r = p;
|
pointer r = p;
|
||||||
p = nullptr;
|
p = nullptr;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(const pointer p2 = pointer()) noexcept
|
constexpr void reset(const pointer p2 = pointer()) noexcept
|
||||||
{
|
{
|
||||||
const pointer r = p;
|
const pointer r = p;
|
||||||
p = p2;
|
p = p2;
|
||||||
|
@ -95,29 +95,29 @@ struct unique_ptr
|
||||||
d(r);
|
d(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(unique_ptr& r) noexcept
|
constexpr void swap(unique_ptr& r) noexcept
|
||||||
{
|
{
|
||||||
using ctl::swap;
|
using ctl::swap;
|
||||||
swap(p, r.p);
|
swap(p, r.p);
|
||||||
swap(d, r.d);
|
swap(d, r.d);
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer get() const noexcept
|
constexpr pointer get() const noexcept
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
deleter_type& get_deleter() noexcept
|
constexpr deleter_type& get_deleter() noexcept
|
||||||
{
|
{
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleter_type& get_deleter() const noexcept
|
constexpr const deleter_type& get_deleter() const noexcept
|
||||||
{
|
{
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() const noexcept
|
constexpr explicit operator bool() const noexcept
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue