Salome HOME
a useful method
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 30 Dec 2016 06:47:00 +0000 (07:47 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 30 Dec 2016 06:47:00 +0000 (07:47 +0100)
src/MEDCoupling/MCAuto.hxx

index 99de255ca09f6f941e1bdbce081757f8bbfd83f4..913024e841927a5f6d550fb62b39e30c6ca53599 100644 (file)
@@ -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; }