From 5edfc1ea42220caa2154998764b5de3f674a02a9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 20 Mar 2022 16:30:14 +0100 Subject: [PATCH] Base: [skip ci] lgtm: Inconsistent definition of copy constructor and assignment ('Rule of Two') --- src/Base/SmartPtrPy.cpp | 6 ++++++ src/Base/SmartPtrPy.h | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Base/SmartPtrPy.cpp b/src/Base/SmartPtrPy.cpp index edd1c98ee4..1a6bdf8604 100644 --- a/src/Base/SmartPtrPy.cpp +++ b/src/Base/SmartPtrPy.cpp @@ -67,6 +67,12 @@ namespace Py { Py::_XINCREF( p ); } + SmartPtr &SmartPtr::operator=( const SmartPtr &rhs ) + { + set( rhs.ptr() ); + return *this; + } + SmartPtr &SmartPtr::operator=( const Object &rhs ) { set( rhs.ptr() ); diff --git a/src/Base/SmartPtrPy.h b/src/Base/SmartPtrPy.h index 28fa59cf99..1215cddff5 100644 --- a/src/Base/SmartPtrPy.h +++ b/src/Base/SmartPtrPy.h @@ -24,6 +24,8 @@ #ifndef PY_SMARTPTRPY_H #define PY_SMARTPTRPY_H +#include + // forward declarations typedef struct _object PyObject; @@ -57,7 +59,8 @@ public: SmartPtr(const SmartPtr &ob); // Assignment acquires new ownership of pointer - SmartPtr &operator=( const Object &SmartPtr ); + SmartPtr &operator=( const SmartPtr &rhs ); + SmartPtr &operator=( const Object &rhs ); SmartPtr &operator=(PyObject *rhsp);