forked from boostorg/smart_ptr
Add a self-assignment assert to reset(). Also add an overload of reset to
allow resetting to a new pointer with a new deletion function. [SVN r12491]
This commit is contained in:
@ -72,6 +72,7 @@ public:
|
|||||||
|
|
||||||
void reset(T * p = 0)
|
void reset(T * p = 0)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(p == 0 || p != px);
|
||||||
shared_array(p).swap(*this);
|
shared_array(p).swap(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@ public:
|
|||||||
|
|
||||||
void reset(T * p = 0)
|
void reset(T * p = 0)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(p == 0 || p != px);
|
||||||
shared_ptr(p).swap(*this);
|
shared_ptr(p).swap(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ public:
|
|||||||
|
|
||||||
void reset(T * p = 0)
|
void reset(T * p = 0)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(p == 0 || p != px);
|
||||||
this_type(p).swap(*this);
|
this_type(p).swap(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash
|
#ifdef BOOST_MSVC // moved here to work around VC++ compiler crash
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable:4284) // odd return type for operator->
|
# pragma warning(disable:4284) // odd return type for operator->
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -144,9 +144,15 @@ public:
|
|||||||
|
|
||||||
void reset(T * p = 0)
|
void reset(T * p = 0)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(p == 0 || p != px);
|
||||||
this_type(p).swap(*this);
|
this_type(p).swap(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename D> void reset(T * p, D d)
|
||||||
|
{
|
||||||
|
this_type(p, d).swap(*this);
|
||||||
|
}
|
||||||
|
|
||||||
typename detail::shared_ptr_traits<T>::reference operator* () const // never throws
|
typename detail::shared_ptr_traits<T>::reference operator* () const // never throws
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(px != 0);
|
BOOST_ASSERT(px != 0);
|
||||||
|
Reference in New Issue
Block a user