summaryrefslogtreecommitdiff
path: root/third_party/base/nonstd_unique_ptr.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-09-22 15:22:48 -0700
committerTom Sepez <tsepez@chromium.org>2015-09-22 15:22:48 -0700
commit7cfadd97215265afd7771d6c36b5cfda54427169 (patch)
treea85b534ee3c0f3b7289f530f3f7436f31ce0b39a /third_party/base/nonstd_unique_ptr.h
parent20ab0232053a819249322532011c65ed42e29a35 (diff)
downloadpdfium-7cfadd97215265afd7771d6c36b5cfda54427169.tar.xz
Merge to XFA: Add nonstd::unique_ptr move assigment operator.
(cherry picked from commit dd7a7f012424ec8505830710ac0dd0183203c189) Original Review URL: https://codereview.chromium.org/1358163002 . TBR=jyasskin@chromium.org Review URL: https://codereview.chromium.org/1362763002 .
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]; }