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

Unified Diff: base/memory/ref_counted.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 | « no previous file | base/move.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted.h
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index 26c65519664ee0eddb8cf7d2c8687232f8ec36f1..85dd433e0544160e2427c455abec80c48b028495 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -14,7 +14,6 @@
#ifndef NDEBUG
#include "base/logging.h"
#endif
-#include "base/move.h"
#include "base/threading/thread_collision_warner.h"
#include "build/build_config.h"
@@ -265,7 +264,6 @@ class RefCountedData
//
template <class T>
class scoped_refptr {
- TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(scoped_refptr)
public:
typedef T element_type;
@@ -277,17 +275,24 @@ class scoped_refptr {
AddRef(ptr_);
}
+ // Copy constructor.
scoped_refptr(const scoped_refptr<T>& r) : ptr_(r.ptr_) {
if (ptr_)
AddRef(ptr_);
}
+ // Copy conversion constructor.
template <typename U>
scoped_refptr(const scoped_refptr<U>& r) : ptr_(r.get()) {
if (ptr_)
AddRef(ptr_);
}
+ // Move constructor. This is required in addition to the conversion
+ // constructor below in order for clang to warn about pessimizing moves.
+ scoped_refptr(scoped_refptr&& r) : ptr_(r.get()) { r.ptr_ = nullptr; }
+
+ // Move conversion constructor.
template <typename U>
scoped_refptr(scoped_refptr<U>&& r) : ptr_(r.get()) {
r.ptr_ = nullptr;
« no previous file with comments | « no previous file | base/move.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698