Added a reset method to SharedPtr, which allows NULLifying it.

svn-id: r33400
This commit is contained in:
Johannes Schickel 2008-07-29 09:16:53 +00:00
parent 598394e5b8
commit 290f76a623
2 changed files with 13 additions and 0 deletions

View file

@ -170,6 +170,16 @@ public:
*/
bool unique() const { return refCount() == 1; }
/**
* Resets the SharedPtr object to a NULL pointer.
*/
void reset() {
decRef();
_deletion = 0;
_refCount = 0;
_pointer = 0;
}
/**
* Returns the number of references to the assigned pointer.
* This should just be used for debugging purposes.

View file

@ -61,6 +61,9 @@ class PtrTestSuite : public CxxTest::TestSuite
TS_ASSERT(p1 != 0);
TS_ASSERT(p2 == 0);
p1.reset();
TS_ASSERT(!p1);
}
struct A {