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}
This commit is contained in:
Danil Chapovalov 2016-07-29 19:14:56 +02:00
parent 3d7346fd46
commit 70cfc14af6

View File

@ -63,7 +63,7 @@
#ifndef WEBRTC_BASE_SCOPED_REF_PTR_H_
#define WEBRTC_BASE_SCOPED_REF_PTR_H_
#include <stddef.h>
#include <memory>
namespace rtc {
@ -134,6 +134,17 @@ class scoped_refptr {
return *this = r.get();
}
scoped_refptr<T>& operator=(scoped_refptr<T>&& r) {
scoped_refptr<T>(std::move(r)).swap(*this);
return *this;
}
template <typename U>
scoped_refptr<T>& operator=(scoped_refptr<U>&& r) {
scoped_refptr<T>(std::move(r)).swap(*this);
return *this;
}
void swap(T** pp) {
T* p = ptr_;
ptr_ = *pp;