diff --git a/src/alias_registry.hh b/src/alias_registry.hh index 8fa277c3..49571c1e 100644 --- a/src/alias_registry.hh +++ b/src/alias_registry.hh @@ -11,7 +11,7 @@ namespace Kakoune class AliasRegistry : public SafeCountable { public: - AliasRegistry(AliasRegistry& parent) : m_parent(&parent) {} + AliasRegistry(AliasRegistry& parent) : SafeCountable{}, m_parent(&parent) {} void add_alias(String alias, String command); void remove_alias(StringView alias); StringView operator[](StringView alias) const; diff --git a/src/hook_manager.hh b/src/hook_manager.hh index 9cfa4a9b..66baecf3 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -14,7 +14,7 @@ class Context; class HookManager : public SafeCountable { public: - HookManager(HookManager& parent) : m_parent(&parent) {} + HookManager(HookManager& parent) : SafeCountable{}, m_parent(&parent) {} void add_hook(StringView hook_name, String group, Regex filter, String commands); void remove_hooks(StringView group); diff --git a/src/ref_ptr.hh b/src/ref_ptr.hh index 5711ced2..0dbc0be7 100644 --- a/src/ref_ptr.hh +++ b/src/ref_ptr.hh @@ -8,8 +8,15 @@ namespace Kakoune struct RefCountable { - int refcount = 0; + RefCountable() = default; + RefCountable(const RefCountable&) {} + RefCountable(RefCountable&&) {} virtual ~RefCountable() = default; + + RefCountable& operator=(const RefCountable&) { return *this; } + RefCountable& operator=(RefCountable&&) { return *this; } + + int refcount = 0; }; struct RefCountablePolicy diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh index 4d83a46d..38d58046 100644 --- a/src/safe_ptr.hh +++ b/src/safe_ptr.hh @@ -24,7 +24,7 @@ class SafeCountable { public: #ifdef KAK_DEBUG - SafeCountable() : m_count(0) {} + SafeCountable() {} ~SafeCountable() { kak_assert(m_count == 0); @@ -33,6 +33,12 @@ public: #endif } + SafeCountable(const SafeCountable&) {} + SafeCountable(SafeCountable&&) {} + + SafeCountable& operator=(const SafeCountable& other) { return *this; } + SafeCountable& operator=(SafeCountable&& other) { return *this; } + private: friend struct SafeCountablePolicy; #ifdef SAFE_PTR_TRACK_CALLSTACKS @@ -45,7 +51,7 @@ private: mutable Vector m_callstacks; #endif - mutable int m_count; + mutable int m_count = 0; #endif };