diff options
-rw-r--r-- | cutl/shared-ptr.hxx | 10 | ||||
-rw-r--r-- | cutl/shared-ptr/base.txx | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/cutl/shared-ptr.hxx b/cutl/shared-ptr.hxx index 0fc948b..de85447 100644 --- a/cutl/shared-ptr.hxx +++ b/cutl/shared-ptr.hxx @@ -118,6 +118,16 @@ namespace cutl return r; } + void + reset (X* x) + { + if (x_ != 0) + base::dec (x_); + + base::reset (x); + x_ = x; + } + std::size_t count () const { diff --git a/cutl/shared-ptr/base.txx b/cutl/shared-ptr/base.txx index 92ffa17..dae6083 100644 --- a/cutl/shared-ptr/base.txx +++ b/cutl/shared-ptr/base.txx @@ -103,6 +103,12 @@ namespace cutl } void + reset (X const* p) + { + counter_ = p ? bits::counter (p) : 0; + } + + void inc (X*) { (*counter_)++; @@ -133,6 +139,9 @@ namespace cutl counter_ops (Y const*) {} void + reset (Y const*) {} + + void inc (shared_base* p) {p->_inc_ref ();} void |