Added a default constructor to shared_count and shared_ptr for incomplete types (void).

[SVN r12815]
This commit is contained in:
Peter Dimov
2002-02-15 13:31:58 +00:00
parent 5e2f514140
commit 5a6cd1cf3e
3 changed files with 57 additions and 14 deletions
+5 -1
View File
@@ -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
{
+12 -3
View File
@@ -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);
}