From 6453ce739457f7c00ca65bd574f10b5fa5966ac1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 25 Feb 2018 00:20:10 +1100 Subject: [PATCH] RefPtr: Add some more noexcept specifications --- src/ref_ptr.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ref_ptr.hh b/src/ref_ptr.hh index 0dbc0be7..facd49b1 100644 --- a/src/ref_ptr.hh +++ b/src/ref_ptr.hh @@ -22,7 +22,7 @@ struct RefCountable struct RefCountablePolicy { 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 {} }; @@ -31,7 +31,7 @@ struct RefPtr { RefPtr() = default; explicit RefPtr(T* ptr) : m_ptr(ptr) { acquire(); } - ~RefPtr() { release(); } + ~RefPtr() noexcept(noexcept(std::declval().release())) { release(); } RefPtr(const RefPtr& other) : m_ptr(other.m_ptr) { acquire(); } RefPtr(RefPtr&& other) noexcept(noexcept(std::declval().moved(nullptr))) @@ -103,6 +103,7 @@ private: [[gnu::always_inline]] void release() + noexcept(noexcept(Policy::dec_ref(nullptr, nullptr))) { if (m_ptr) Policy::dec_ref(m_ptr, this);