forked from boostorg/smart_ptr
Added a default constructor to shared_count and shared_ptr for incomplete types (void).
[SVN r12815]
This commit is contained in:
@@ -186,6 +186,10 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
shared_count(): pi_(new counted_base(1, 1))
|
||||
{
|
||||
}
|
||||
|
||||
template<class P, class D> shared_count(P p, D d): pi_(0)
|
||||
{
|
||||
try
|
||||
@@ -221,7 +225,7 @@ public:
|
||||
pi_->add_ref();
|
||||
}
|
||||
|
||||
explicit shared_count(weak_count const & r); // throws bad_weak_to_shared_cast when r.use_count() == 0
|
||||
explicit shared_count(weak_count const & r); // throws use_count_is_zero when r.use_count() == 0
|
||||
|
||||
shared_count & operator= (shared_count const & r) // nothrow
|
||||
{
|
||||
|
||||
@@ -81,7 +81,11 @@ public:
|
||||
|
||||
typedef T element_type;
|
||||
|
||||
explicit shared_ptr(T * p = 0): px(p), pn(p, deleter())
|
||||
shared_ptr(): px(0), pn()
|
||||
{
|
||||
}
|
||||
|
||||
explicit shared_ptr(T * p): px(p), pn(p, deleter()) // requires complete type
|
||||
{
|
||||
}
|
||||
|
||||
@@ -157,9 +161,14 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
void reset(T * p = 0)
|
||||
void reset()
|
||||
{
|
||||
BOOST_ASSERT(p == 0 || p != px);
|
||||
this_type().swap(*this);
|
||||
}
|
||||
|
||||
void reset(T * p) // requires complete type
|
||||
{
|
||||
BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors
|
||||
this_type(p).swap(*this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user