Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: skia/ext/refptr.h

Issue 1477643002: Remove the TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03 macro. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@basepass
Patch Set: type-with-move: no-media Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ssl/threaded_ssl_private_key.cc ('k') | skia/ext/refptr_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/refptr.h
diff --git a/skia/ext/refptr.h b/skia/ext/refptr.h
index a7ba7ffb78542a7ec64e90dae696d0dfcd2e08fc..93f12204126752ed8390dd5ec0c30155100451a0 100644
--- a/skia/ext/refptr.h
+++ b/skia/ext/refptr.h
@@ -6,8 +6,8 @@
#define SKIA_EXT_REFPTR_H_
#include <algorithm>
+#include <cstddef>
-#include "base/move.h"
#include "third_party/skia/include/core/SkRefCnt.h"
namespace skia {
@@ -52,23 +52,29 @@ namespace skia {
// for you.
template<typename T>
class RefPtr {
- TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(RefPtr)
public:
RefPtr() : ptr_(nullptr) {}
- RefPtr(decltype(nullptr)) : ptr_(nullptr) {}
+ RefPtr(std::nullptr_t) : ptr_(nullptr) {}
+ // Copy constructor.
RefPtr(const RefPtr& other)
: ptr_(other.get()) {
SkSafeRef(ptr_);
}
+ // Copy conversion constructor.
template<typename U>
RefPtr(const RefPtr<U>& other)
: ptr_(other.get()) {
SkSafeRef(ptr_);
}
+ // Move constructor. This is required in addition to the conversion
+ // constructor below in order for clang to warn about pessimizing moves.
+ RefPtr(RefPtr&& other) : ptr_(other.get()) { other.ptr_ = nullptr; }
+
+ // Move conversion constructor.
template <typename U>
RefPtr(RefPtr<U>&& other)
: ptr_(other.get()) {
@@ -79,7 +85,7 @@ class RefPtr {
clear();
}
- RefPtr& operator=(decltype(nullptr)) {
+ RefPtr& operator=(std::nullptr_t) {
clear();
return *this;
}
@@ -97,7 +103,7 @@ class RefPtr {
template <typename U>
RefPtr& operator=(RefPtr<U>&& other) {
- RefPtr<T> temp(other.Pass());
+ RefPtr<T> temp(std::move(other));
std::swap(ptr_, temp.ptr_);
return *this;
}
« no previous file with comments | « net/ssl/threaded_ssl_private_key.cc ('k') | skia/ext/refptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698