From 70cfc14af67ce2f85143fefa9ff28703445d0f43 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 29 Jul 2016 19:14:56 +0200 Subject: [PATCH] Adds move assignment operator to scoped_refptr Implementation borrowed from chromium. BUG=webrtc:5556 R=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/2193443002 . Cr-Commit-Position: refs/heads/master@{#13577} --- webrtc/base/scoped_ref_ptr.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webrtc/base/scoped_ref_ptr.h b/webrtc/base/scoped_ref_ptr.h index ceee445216..df669121dc 100644 --- a/webrtc/base/scoped_ref_ptr.h +++ b/webrtc/base/scoped_ref_ptr.h @@ -63,7 +63,7 @@ #ifndef WEBRTC_BASE_SCOPED_REF_PTR_H_ #define WEBRTC_BASE_SCOPED_REF_PTR_H_ -#include +#include namespace rtc { @@ -134,6 +134,17 @@ class scoped_refptr { return *this = r.get(); } + scoped_refptr& operator=(scoped_refptr&& r) { + scoped_refptr(std::move(r)).swap(*this); + return *this; + } + + template + scoped_refptr& operator=(scoped_refptr&& r) { + scoped_refptr(std::move(r)).swap(*this); + return *this; + } + void swap(T** pp) { T* p = ptr_; ptr_ = *pp;