#2172: Add Poco::AutoPtr::reset() and Poco::SharedPtr::reset()

This commit is contained in:
Günter Obiltschnig 2018-02-21 17:58:05 +01:00
parent db1ee417ab
commit 2870dd898c
2 changed files with 52 additions and 1 deletions

View File

@ -139,6 +139,36 @@ public:
return *this;
}
void reset()
{
if (_ptr)
{
_ptr->release();
_ptr = 0;
}
}
void reset(C* ptr)
{
assign(ptr);
}
void reset(C* ptr, bool shared)
{
assign(ptr, shared);
}
void reset(const AutoPtr& ptr)
{
assign(ptr);
}
template <class Other>
void reset(const AutoPtr<Other>& ptr)
{
assign<Other>(ptr);
}
AutoPtr& operator = (C* ptr)
{
return assign(ptr);

View File

@ -77,7 +77,7 @@ public:
{
}
~SharedPtr()
~SharedPtr() noexcept
{
}
@ -108,6 +108,27 @@ public:
return *this;
}
void reset() noexcept
{
_ptr.reset();
}
void reset(C* ptr)
{
_ptr.reset(ptr);
}
void reset(const SharedPtr& ptr)
{
assign(ptr);
}
template <class Other>
void reset(const SharedPtr<Other>& ptr)
{
assign<Other>(ptr);
}
SharedPtr& operator = (C* ptr)
{
return assign(ptr);