mirror of
https://github.com/boostorg/smart_ptr.git
synced 2026-04-28 18:13:34 +02:00
Consistent 'bool' conversions; scoped_ptr(auto_ptr); get_pointer(scoped_ptr) added.
[SVN r14496]
This commit is contained in:
@@ -33,6 +33,8 @@ private:
|
||||
scoped_array(scoped_array const &);
|
||||
scoped_array & operator=(scoped_array const &);
|
||||
|
||||
typedef scoped_array<T> this_type;
|
||||
|
||||
public:
|
||||
|
||||
typedef T element_type;
|
||||
@@ -67,6 +69,20 @@ public:
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
void swap(scoped_array & b) // never throws
|
||||
{
|
||||
T * tmp = b.ptr;
|
||||
|
||||
Reference in New Issue
Block a user