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

Unified Diff: base/memory/scoped_ptr_unittest.cc

Issue 1410703002: RValue emulation magically works in C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: With rvalue references Created 5 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_ptr_unittest.cc
diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc
index 71d995c452e826ad1faeb28f315433077f338e88..dcb3e85d91c7e16bebbe3d3390fa2dce9f73fe91 100644
--- a/base/memory/scoped_ptr_unittest.cc
+++ b/base/memory/scoped_ptr_unittest.cc
@@ -5,6 +5,7 @@
#include "base/memory/scoped_ptr.h"
#include <sstream>
+#include <vector>
#include "base/basictypes.h"
#include "base/bind.h"
@@ -716,3 +717,31 @@ TEST(ScopedPtrTest, ReferenceCycle) {
// definition of unique_ptr::reset in C++11.
a->b.reset();
}
+
+template<typename T>
+class ScopedPtr2 {
+ MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(ScopedPtr2)
+ public:
+ explicit ScopedPtr2(T* p) : p_(p) { }
+ ~ScopedPtr2() { delete p_; }
+
+ ScopedPtr2(ScopedPtr2&& rhs) : p_(nullptr) {
+ using std::swap;
+ swap(p_, rhs.p_);
+ }
+
+ ScopedPtr2& operator=(ScopedPtr2&& rhs) {
+ using std::swap;
+ swap(p_, rhs.p_);
+ }
+
+ private:
+ T* p_;
+};
+
+TEST(ScopedPtrTest, VectorOfScopedPtrs) {
+ class TestClassPleaseIgnore {
+ };
+ std::vector<ScopedPtr2<TestClassPleaseIgnore>> x;
+ x.push_back(ScopedPtr2<TestClassPleaseIgnore>(new TestClassPleaseIgnore));
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698