Add some noexcept to pointer policies

This commit is contained in:
Maxime Coste 2017-01-31 21:45:55 +00:00
parent 34870eb353
commit f44415cee4
2 changed files with 7 additions and 7 deletions

View File

@ -14,7 +14,7 @@ struct RefCountable
struct RefCountablePolicy 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 dec_ref(RefCountable* r, void*) { if (--r->refcount == 0) delete r; }
static void ptr_moved(RefCountable*, void*, void*) noexcept {} static void ptr_moved(RefCountable*, void*, void*) noexcept {}
}; };

View File

@ -52,7 +52,7 @@ private:
struct SafeCountablePolicy struct SafeCountablePolicy
{ {
#ifdef KAK_DEBUG #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; ++sc->m_count;
#ifdef SAFE_PTR_TRACK_CALLSTACKS #ifdef SAFE_PTR_TRACK_CALLSTACKS
@ -60,7 +60,7 @@ struct SafeCountablePolicy
#endif #endif
} }
static void dec_ref(const SafeCountable* sc, void* ptr) static void dec_ref(const SafeCountable* sc, void* ptr) noexcept
{ {
--sc->m_count; --sc->m_count;
kak_assert(sc->m_count >= 0); kak_assert(sc->m_count >= 0);
@ -72,7 +72,7 @@ struct SafeCountablePolicy
#endif #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 #ifdef SAFE_PTR_TRACK_CALLSTACKS
auto it = std::find_if(sc->m_callstacks.begin(), sc->m_callstacks.end(), auto it = std::find_if(sc->m_callstacks.begin(), sc->m_callstacks.end(),
@ -82,9 +82,9 @@ struct SafeCountablePolicy
#endif #endif
} }
#else #else
static void inc_ref(const SafeCountable*, void* ptr) {} static void inc_ref(const SafeCountable*, void* ptr) noexcept {}
static void dec_ref(const SafeCountable*, void* ptr) {} static void dec_ref(const SafeCountable*, void* ptr) noexcept {}
static void ptr_moved(const SafeCountable*, void*, void*) {} static void ptr_moved(const SafeCountable*, void*, void*) noexcept {}
#endif #endif
}; };