This is an automated email from the ASF dual-hosted git repository.

wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 8256f7f0 scoped_refptr add move constructor (#2284)
8256f7f0 is described below

commit 8256f7f0d28169f295a2c34b513993276a93461b
Author: byronhe <[email protected]>
AuthorDate: Sun Jun 25 17:11:28 2023 +0800

    scoped_refptr add move constructor (#2284)
    
    * scoped_refptr add move constructor
    
    * scoped_refptr add move constructor
---
 src/butil/memory/ref_counted.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/butil/memory/ref_counted.h b/src/butil/memory/ref_counted.h
index 5f01fc1b..8fbb5d0d 100644
--- a/src/butil/memory/ref_counted.h
+++ b/src/butil/memory/ref_counted.h
@@ -285,6 +285,21 @@ class scoped_refptr {
       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();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to