From bab86dc8d745263299949590db82952942c5c79d Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 30 Dec 2016 07:47:00 +0100 Subject: [PATCH] a useful method --- src/MEDCoupling/MCAuto.hxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MEDCoupling/MCAuto.hxx b/src/MEDCoupling/MCAuto.hxx index 99de255ca..913024e84 100644 --- a/src/MEDCoupling/MCAuto.hxx +++ b/src/MEDCoupling/MCAuto.hxx @@ -40,6 +40,7 @@ namespace MEDCoupling bool operator==(const T *other) const { return _ptr==other; } MCAuto &operator=(const MCAuto& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; } MCAuto &operator=(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; } + void takeRef(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; if(_ptr) _ptr->incrRef(); } } T *operator->() { return _ptr ; } const T *operator->() const { return _ptr; } T& operator*() { return *_ptr; } -- 2.39.2