scoped_refptr add move constructor (#2284)
* scoped_refptr add move constructor
* scoped_refptr add move constructor
diff --git a/src/butil/memory/ref_counted.h b/src/butil/memory/ref_counted.h
index 5f01fc1..8fbb5d0 100644
--- a/src/butil/memory/ref_counted.h
+++ b/src/butil/memory/ref_counted.h
@@ -285,6 +285,21 @@
ptr_->AddRef();
}
+ scoped_refptr(scoped_refptr<T>&& r) noexcept {
+ if (r.ptr_){
+ ptr_ = r.ptr_;
+ r.ptr_ = nullptr;
+ }
+ }
+
+ template <typename U>
+ scoped_refptr(scoped_refptr<U>&& r) noexcept {
+ if (r.ptr_){
+ ptr_ = r.ptr_;
+ r.ptr_ = nullptr;
+ }
+ }
+
~scoped_refptr() {
if (ptr_)
ptr_->Release();