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

Unified Diff: third_party/base/nonstd_unique_ptr.h

Issue 1358163002: Add nonstd::unique_ptr move assigment operator. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 3 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 | « pdfium.gyp ('k') | third_party/base/nonstd_unique_ptr_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « pdfium.gyp ('k') | third_party/base/nonstd_unique_ptr_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698