From 0c21cf5247fd7ced4fa85d8d6be5d70af1bc38b3 Mon Sep 17 00:00:00 2001 From: Aliaksander Stsepaniuk Date: Wed, 21 Sep 2022 00:06:52 +0300 Subject: [PATCH] Issue #849 Explicitly disable move operations for pools. --- core/indigo-core/common/base_cpp/obj_pool.h | 9 +++++---- core/indigo-core/common/base_cpp/pool.h | 9 +++++---- core/indigo-core/common/base_cpp/ptr_pool.h | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/core/indigo-core/common/base_cpp/obj_pool.h b/core/indigo-core/common/base_cpp/obj_pool.h index 2bb7823c26..2da11e3c22 100644 --- a/core/indigo-core/common/base_cpp/obj_pool.h +++ b/core/indigo-core/common/base_cpp/obj_pool.h @@ -19,19 +19,23 @@ #ifndef __obj_pool_h__ #define __obj_pool_h__ +#include "base_cpp/non_copyable.h" #include "base_cpp/pool.h" namespace indigo { template - class ObjPool + class ObjPool : public NonCopyable { public: ObjPool() { } + ObjPool(ObjPool&&) = delete; // explicitly disable move operations + ObjPool& operator=(ObjPool&&) = delete; + ~ObjPool() { clear(); @@ -134,9 +138,6 @@ namespace indigo protected: Pool _pool; - - private: - ObjPool(const ObjPool&); // no implicit copy }; } // namespace indigo diff --git a/core/indigo-core/common/base_cpp/pool.h b/core/indigo-core/common/base_cpp/pool.h index 651c659ca8..b941a30026 100644 --- a/core/indigo-core/common/base_cpp/pool.h +++ b/core/indigo-core/common/base_cpp/pool.h @@ -21,6 +21,7 @@ #include "base_cpp/array.h" #include "base_cpp/exception.h" +#include "base_cpp/non_copyable.h" namespace indigo { @@ -28,7 +29,7 @@ namespace indigo DECL_EXCEPTION(PoolError); template - class Pool + class Pool : public NonCopyable { public: DECL_TPL_ERROR(PoolError); @@ -37,6 +38,9 @@ namespace indigo { } + Pool(Pool&&) = delete; // explicitly disable move operations + Pool& operator=(Pool&&) = delete; + int add() { if (_first == -1) @@ -159,9 +163,6 @@ namespace indigo int _size; // number of _array items used int _first; // index of the first unused element (-1 if all are used) - - private: - Pool(const Pool&); // no implicit copy }; } // namespace indigo diff --git a/core/indigo-core/common/base_cpp/ptr_pool.h b/core/indigo-core/common/base_cpp/ptr_pool.h index 5cabd409ec..633dceec2c 100644 --- a/core/indigo-core/common/base_cpp/ptr_pool.h +++ b/core/indigo-core/common/base_cpp/ptr_pool.h @@ -19,6 +19,7 @@ #ifndef __ptr_pool__ #define __ptr_pool__ +#include "base_cpp/non_copyable.h" #include "base_cpp/pool.h" #ifdef _WIN32 @@ -32,13 +33,16 @@ namespace indigo DECL_EXCEPTION(PtrPoolError); template - class PtrPool + class PtrPool : public NonCopyable { public: explicit PtrPool() { } + PtrPool(PtrPool&&) = delete; // explicitly disable move operations + PtrPool& operator=(PtrPool&&) = delete; + virtual ~PtrPool() { clear(); @@ -122,9 +126,6 @@ namespace indigo protected: Pool _ptrpool; - - private: - PtrPool(const PtrPool&); // no implicit copy }; } // namespace indigo