From c6247430d67d56384e42a4f98d1dd409c157418e Mon Sep 17 00:00:00 2001 From: Gemma Guest <gemma.guest@stfc.ac.uk> Date: Thu, 8 Jun 2017 17:33:58 +0100 Subject: [PATCH] Re #19773 Add missing operator= overload Fixes cppcheck warning. The overload is required to avoid the possibility of an incorrect raw pointer copy. --- Framework/Kernel/src/ConfigService.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index 0a297ec536b..0ef02f940a1 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -112,6 +112,15 @@ public: m_pPtr = static_cast<T *>(this); } + /// Overloaded = operator sets the pointer to the wrapped class + /// and copies over the contents + WrappedObject<T> &operator=(const WrappedObject<T> &rhs) { + if (this != &rhs) { + m_pPtr = static_cast<T *>(this); + *m_pPtr = rhs; + } + return *this; + } /// Overloaded * operator returns the wrapped object pointer const T &operator*() const { return *m_pPtr; } /// Overloaded * operator returns the wrapped object pointer -- GitLab