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

Unified Diff: base/memory/weak_ptr.h

Issue 2094873003: Make base::WeakPtr moveable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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/memory/weak_ptr.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/weak_ptr.h
diff --git a/base/memory/weak_ptr.h b/base/memory/weak_ptr.h
index badf4ee016c837bf9b1ef6a0605df13683baab93..230feff7a67d862cc1a35a3a44227b3e856289df 100644
--- a/base/memory/weak_ptr.h
+++ b/base/memory/weak_ptr.h
@@ -109,10 +109,14 @@ class BASE_EXPORT WeakReference {
};
WeakReference();
- WeakReference(const WeakReference& other);
explicit WeakReference(const Flag* flag);
~WeakReference();
+ WeakReference(WeakReference&& other);
+ WeakReference(const WeakReference& other);
+ WeakReference& operator=(WeakReference&& other) = default;
+ WeakReference& operator=(const WeakReference& other) = default;
+
bool is_valid() const;
private:
@@ -145,6 +149,11 @@ class BASE_EXPORT WeakPtrBase {
WeakPtrBase();
~WeakPtrBase();
+ WeakPtrBase(const WeakPtrBase& other) = default;
+ WeakPtrBase(WeakPtrBase&& other) = default;
+ WeakPtrBase& operator=(const WeakPtrBase& other) = default;
+ WeakPtrBase& operator=(WeakPtrBase&& other) = default;
+
protected:
explicit WeakPtrBase(const WeakReference& ref);
@@ -205,10 +214,13 @@ class WeakPtr : public internal::WeakPtrBase {
WeakPtr(std::nullptr_t) : ptr_(nullptr) {}
// Allow conversion from U to T provided U "is a" T. Note that this
- // is separate from the (implicit) copy constructor.
+ // is separate from the (implicit) copy and move constructors.
template <typename U>
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other), ptr_(other.ptr_) {
}
+ template <typename U>
+ WeakPtr(WeakPtr<U>&& other) : WeakPtrBase(other), ptr_(other.ptr_) {
vmpstr 2016/06/24 00:17:39 WeakPtrBase(std::move(other))
Marijn Kruisselbrink 2016/06/24 00:50:15 Done
+ }
T* get() const { return ref_.is_valid() ? ptr_ : nullptr; }
« no previous file with comments | « no previous file | base/memory/weak_ptr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698