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

Unified Diff: base/memory/scoped_vector.h

Issue 9207021: Transfer the C++03 move-only type emulation into base/move.h and also make ScopedVector move-only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 8 years, 11 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 | « base/memory/scoped_ptr.h ('k') | base/memory/scoped_vector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_vector.h
diff --git a/base/memory/scoped_vector.h b/base/memory/scoped_vector.h
index 832d9dd04661d3569dc7b4e93d5464cad754d0df..ba2e1a0e1f1b2fd58844ffb7aba71b57ace961a2 100644
--- a/base/memory/scoped_vector.h
+++ b/base/memory/scoped_vector.h
@@ -9,12 +9,15 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/move.h"
#include "base/stl_util.h"
// ScopedVector wraps a vector deleting the elements from its
// destructor.
template <class T>
class ScopedVector {
+ MOVE_ONLY_TYPE_FOR_CPP_03(ScopedVector, RValue);
+
public:
typedef typename std::vector<T*>::iterator iterator;
typedef typename std::vector<T*>::const_iterator const_iterator;
@@ -24,6 +27,12 @@ class ScopedVector {
ScopedVector() {}
~ScopedVector() { reset(); }
+ ScopedVector(RValue& other) { swap(other); }
+
+ ScopedVector& operator=(RValue& rhs) {
+ swap(rhs);
+ return *this;
+ }
std::vector<T*>* operator->() { return &v; }
const std::vector<T*>* operator->() const { return &v; }
@@ -89,8 +98,6 @@ class ScopedVector {
}
private:
std::vector<T*> v;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedVector);
};
#endif // BASE_MEMORY_SCOPED_VECTOR_H_
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | base/memory/scoped_vector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698