mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 17:31:44 +03:00
RefPtr: Add some more noexcept specifications
This commit is contained in:
parent
67424aae1e
commit
6453ce7394
@ -22,7 +22,7 @@ struct RefCountable
|
|||||||
struct RefCountablePolicy
|
struct RefCountablePolicy
|
||||||
{
|
{
|
||||||
static void inc_ref(RefCountable* r, void*) noexcept { ++r->refcount; }
|
static void inc_ref(RefCountable* r, void*) noexcept { ++r->refcount; }
|
||||||
static void dec_ref(RefCountable* r, void*) { if (--r->refcount == 0) delete r; }
|
static void dec_ref(RefCountable* r, void*) noexcept(noexcept(r->~RefCountable())) { if (--r->refcount == 0) delete r; }
|
||||||
static void ptr_moved(RefCountable*, void*, void*) noexcept {}
|
static void ptr_moved(RefCountable*, void*, void*) noexcept {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ struct RefPtr
|
|||||||
{
|
{
|
||||||
RefPtr() = default;
|
RefPtr() = default;
|
||||||
explicit RefPtr(T* ptr) : m_ptr(ptr) { acquire(); }
|
explicit RefPtr(T* ptr) : m_ptr(ptr) { acquire(); }
|
||||||
~RefPtr() { release(); }
|
~RefPtr() noexcept(noexcept(std::declval<RefPtr>().release())) { release(); }
|
||||||
RefPtr(const RefPtr& other) : m_ptr(other.m_ptr) { acquire(); }
|
RefPtr(const RefPtr& other) : m_ptr(other.m_ptr) { acquire(); }
|
||||||
RefPtr(RefPtr&& other)
|
RefPtr(RefPtr&& other)
|
||||||
noexcept(noexcept(std::declval<RefPtr>().moved(nullptr)))
|
noexcept(noexcept(std::declval<RefPtr>().moved(nullptr)))
|
||||||
@ -103,6 +103,7 @@ private:
|
|||||||
|
|
||||||
[[gnu::always_inline]]
|
[[gnu::always_inline]]
|
||||||
void release()
|
void release()
|
||||||
|
noexcept(noexcept(Policy::dec_ref(nullptr, nullptr)))
|
||||||
{
|
{
|
||||||
if (m_ptr)
|
if (m_ptr)
|
||||||
Policy::dec_ref(m_ptr, this);
|
Policy::dec_ref(m_ptr, this);
|
||||||
|
Loading…
Reference in New Issue
Block a user