From f44415cee483c988c4f611cd4544f5f5f44844b7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 31 Jan 2017 21:45:55 +0000 Subject: [PATCH] Add some noexcept to pointer policies --- src/ref_ptr.hh | 2 +- src/safe_ptr.hh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ref_ptr.hh b/src/ref_ptr.hh index d9fa4ab5..5711ced2 100644 --- a/src/ref_ptr.hh +++ b/src/ref_ptr.hh @@ -14,7 +14,7 @@ struct RefCountable struct RefCountablePolicy { - static void inc_ref(RefCountable* r, void*) { ++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 ptr_moved(RefCountable*, void*, void*) noexcept {} }; diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh index efe5da80..4d83a46d 100644 --- a/src/safe_ptr.hh +++ b/src/safe_ptr.hh @@ -52,7 +52,7 @@ private: struct SafeCountablePolicy { #ifdef KAK_DEBUG - static void inc_ref(const SafeCountable* sc, void* ptr) + static void inc_ref(const SafeCountable* sc, void* ptr) noexcept { ++sc->m_count; #ifdef SAFE_PTR_TRACK_CALLSTACKS @@ -60,7 +60,7 @@ struct SafeCountablePolicy #endif } - static void dec_ref(const SafeCountable* sc, void* ptr) + static void dec_ref(const SafeCountable* sc, void* ptr) noexcept { --sc->m_count; kak_assert(sc->m_count >= 0); @@ -72,7 +72,7 @@ struct SafeCountablePolicy #endif } - static void ptr_moved(const SafeCountable* sc, void* from, void* to) + static void ptr_moved(const SafeCountable* sc, void* from, void* to) noexcept { #ifdef SAFE_PTR_TRACK_CALLSTACKS auto it = std::find_if(sc->m_callstacks.begin(), sc->m_callstacks.end(), @@ -82,9 +82,9 @@ struct SafeCountablePolicy #endif } #else - static void inc_ref(const SafeCountable*, void* ptr) {} - static void dec_ref(const SafeCountable*, void* ptr) {} - static void ptr_moved(const SafeCountable*, void*, void*) {} + static void inc_ref(const SafeCountable*, void* ptr) noexcept {} + static void dec_ref(const SafeCountable*, void* ptr) noexcept {} + static void ptr_moved(const SafeCountable*, void*, void*) noexcept {} #endif };