diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-09-22 15:06:59 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-09-22 15:06:59 -0700 |
commit | dd7a7f012424ec8505830710ac0dd0183203c189 (patch) | |
tree | 94ea1b9a79e207d5cb428d08b922889686c4e09c /third_party/base/nonstd_unique_ptr.h | |
parent | f316bfe37e2fc977376e18f7534aae9824da240a (diff) | |
download | pdfium-dd7a7f012424ec8505830710ac0dd0183203c189.tar.xz |
Add nonstd::unique_ptr move assigment operator.
std::unique_ptr supports move assignment as in:
ptr2 = std::move(ptr1);
R=jyasskin@chromium.org
Review URL: https://codereview.chromium.org/1358163002 .
Diffstat (limited to 'third_party/base/nonstd_unique_ptr.h')
-rw-r--r-- | third_party/base/nonstd_unique_ptr.h | 14 |
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]; } |