mirror of
https://github.com/boostorg/smart_ptr.git
synced 2026-04-29 10:34:16 +02:00
weak_ptr made thread safe, shared->weak conversions, lightweight_mutex added.
[SVN r12786]
This commit is contained in:
@@ -97,6 +97,10 @@ public:
|
||||
|
||||
// generated copy constructor, assignment, destructor are fine
|
||||
|
||||
explicit shared_ptr(weak_ptr<T> const & r): px(r.px), pn(r.pn) // may throw
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Y>
|
||||
shared_ptr(shared_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws
|
||||
{
|
||||
@@ -191,6 +195,20 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user