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

This commit is contained in:
Günter Obiltschnig 2018-02-21 17:48:36 +01:00
parent cf73cfad58
commit de0f5a6b76
2 changed files with 51 additions and 0 deletions

View File

@ -134,6 +134,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

@ -182,6 +182,27 @@ public:
return *this;
}
void reset()
{
assign(0);
}
void reset(C* ptr)
{
assign(ptr);
}
void reset(const SharedPtr& ptr)
{
assign(ptr);
}
template <class Other, class OtherRP>
void reset(const SharedPtr<Other, RC, OtherRP>& ptr)
{
assign<Other, OtherRP>(ptr);
}
SharedPtr& operator = (C* ptr)
{
return assign(ptr);