COMMON: Add a reset method to DisposablePtr
This commit is contained in:
parent
26c096d39d
commit
2c8afb2bd2
1 changed files with 16 additions and 0 deletions
16
common/ptr.h
16
common/ptr.h
|
@ -301,6 +301,22 @@ public:
|
||||||
*/
|
*/
|
||||||
bool operator_bool() const { return _pointer != nullptr; }
|
bool operator_bool() const { return _pointer != nullptr; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the pointer with the new value. Old object will be destroyed
|
||||||
|
*/
|
||||||
|
void reset(PointerType o, DisposeAfterUse::Flag dispose) {
|
||||||
|
if (_dispose) D()(_pointer);
|
||||||
|
_pointer = o;
|
||||||
|
_dispose = dispose;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the pointer. Old object will be destroyed
|
||||||
|
*/
|
||||||
|
void reset() {
|
||||||
|
reset(nullptr, DisposeAfterUse::NO);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the plain pointer value.
|
* Returns the plain pointer value.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue