summaryrefslogtreecommitdiff
path: root/third_party/base/nonstd_unique_ptr.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/base/nonstd_unique_ptr.h')
-rw-r--r--third_party/base/nonstd_unique_ptr.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/third_party/base/nonstd_unique_ptr.h b/third_party/base/nonstd_unique_ptr.h
index 1d1c43f42f..d666e1eeb2 100644
--- a/third_party/base/nonstd_unique_ptr.h
+++ b/third_party/base/nonstd_unique_ptr.h
@@ -176,6 +176,13 @@ class unique_ptr : public unique_ptr_base<C> {
}
}
+ // Move assignment.
+ unique_ptr<C>& operator=(unique_ptr<C>&& that) {
+ if (that.ptr_ != ptr_)
+ reset(that.release());
+ return *this;
+ }
+
private:
// Forbid comparison of unique_ptr types. If C2 != C, it totally doesn't
// make sense, and if C2 == C, it still doesn't make sense because you should
@@ -222,6 +229,13 @@ class unique_ptr<C[]> : public unique_ptr_base<C> {
}
}
+ // Move assignment.
+ unique_ptr<C>& operator=(unique_ptr<C>&& that) {
+ if (that.ptr_ != ptr_)
+ reset(that.release());
+ return *this;
+ }
+
// Support indexing since it is holding array.
C& operator[] (size_t i) { return ptr_[i]; }