Chromium Code Reviews| Index: third_party/base/nonstd_unique_ptr.h |
| diff --git a/third_party/base/nonstd_unique_ptr.h b/third_party/base/nonstd_unique_ptr.h |
| index 1d1c43f42fb4ac706cb1ce01795b03f986e6c58a..96ea19a55d4caebcf3f7ad5b4d5ad19f4d40a895 100644 |
| --- a/third_party/base/nonstd_unique_ptr.h |
| +++ b/third_party/base/nonstd_unique_ptr.h |
| @@ -176,6 +176,18 @@ class unique_ptr : public unique_ptr_base<C> { |
| } |
| } |
| + // Move assignment. |
| + unique_ptr<C>& operator=(unique_ptr<C>&& that) { |
| + if (that.ptr_ != ptr_) { |
|
Jeffrey Yasskin
2015/09/22 20:12:55
Implement this as "reset(that.release());"
Tom Sepez
2015/09/22 22:05:13
Done. clever.
|
| + enum { type_must_be_complete = sizeof(C) }; |
| + C* old_ptr = ptr_; |
| + ptr_ = that.ptr_; |
| + that.ptr_ = nullptr; |
| + delete old_ptr; |
| + } |
| + 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 |