Mark scoped_refptr move and swap operations as noexcept
to align with chromium scoped_refptr implementation
and prefer move over copy in some cases.
Bug: webrtc:11078
Change-Id: I3178e74e611e4b23435668878e6bcc98bc2ce77d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159541
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29768}
diff --git a/api/scoped_refptr.h b/api/scoped_refptr.h
index 67d179f..fa4e83d 100644
--- a/api/scoped_refptr.h
+++ b/api/scoped_refptr.h
@@ -92,10 +92,10 @@
}
// Move constructors.
- scoped_refptr(scoped_refptr<T>&& r) : ptr_(r.release()) {}
+ scoped_refptr(scoped_refptr<T>&& r) noexcept : ptr_(r.release()) {}
template <typename U>
- scoped_refptr(scoped_refptr<U>&& r) : ptr_(r.release()) {}
+ scoped_refptr(scoped_refptr<U>&& r) noexcept : ptr_(r.release()) {}
~scoped_refptr() {
if (ptr_)
@@ -136,24 +136,24 @@
return *this = r.get();
}
- scoped_refptr<T>& operator=(scoped_refptr<T>&& r) {
+ scoped_refptr<T>& operator=(scoped_refptr<T>&& r) noexcept {
scoped_refptr<T>(std::move(r)).swap(*this);
return *this;
}
template <typename U>
- scoped_refptr<T>& operator=(scoped_refptr<U>&& r) {
+ scoped_refptr<T>& operator=(scoped_refptr<U>&& r) noexcept {
scoped_refptr<T>(std::move(r)).swap(*this);
return *this;
}
- void swap(T** pp) {
+ void swap(T** pp) noexcept {
T* p = ptr_;
ptr_ = *pp;
*pp = p;
}
- void swap(scoped_refptr<T>& r) { swap(&r.ptr_); }
+ void swap(scoped_refptr<T>& r) noexcept { swap(&r.ptr_); }
protected:
T* ptr_;