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

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: reset(that.release()) and same for []s. 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
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..d666e1eeb2586d093a496cd29eaf51f2a37d7c9a 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]; }
« pdfium.gyp ('K') | « 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