Consistent 'bool' conversions; scoped_ptr(auto_ptr); get_pointer(scoped_ptr) added.

[SVN r14496]
This commit is contained in:
Peter Dimov
2002-07-17 15:15:39 +00:00
parent af6fe18c9d
commit 547888d507
4 changed files with 80 additions and 15 deletions
+14 -14
View File
@@ -206,6 +206,20 @@ public:
return px;
}
// implicit conversion to "bool"
typedef T * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws
{
return px == 0? 0: &this_type::get;
}
bool operator! () const // never throws
{
return px == 0;
}
bool unique() const // never throws
{
return pn.unique();
@@ -216,20 +230,6 @@ public:
return pn.use_count();
}
// implicit conversion to "bool"
typedef long (this_type::*bool_type)() const;
operator bool_type() const // never throws
{
return px == 0? 0: &this_type::use_count;
}
bool operator! () const // never throws
{
return px == 0;
}
void swap(shared_ptr<T> & other) // never throws
{
std::swap(px, other.px);