OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_ | 5 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_ |
6 #define BASE_MEMORY_SCOPED_VECTOR_H_ | 6 #define BASE_MEMORY_SCOPED_VECTOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/move.h" | 14 #include "base/macros.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 | 16 |
17 // ScopedVector wraps a vector deleting the elements from its | 17 // ScopedVector wraps a vector deleting the elements from its |
18 // destructor. | 18 // destructor. |
19 // | 19 // |
20 // TODO(http://crbug.com/554289): DEPRECATED: Use std::vector instead (now that | 20 // TODO(http://crbug.com/554289): DEPRECATED: Use std::vector instead (now that |
21 // we have support for moveable types inside containers). | 21 // we have support for moveable types inside containers). |
22 template <class T> | 22 template <class T> |
23 class ScopedVector { | 23 class ScopedVector { |
24 MOVE_ONLY_TYPE_FOR_CPP_03(ScopedVector) | |
25 | |
26 public: | 24 public: |
27 typedef typename std::vector<T*>::allocator_type allocator_type; | 25 typedef typename std::vector<T*>::allocator_type allocator_type; |
28 typedef typename std::vector<T*>::size_type size_type; | 26 typedef typename std::vector<T*>::size_type size_type; |
29 typedef typename std::vector<T*>::difference_type difference_type; | 27 typedef typename std::vector<T*>::difference_type difference_type; |
30 typedef typename std::vector<T*>::pointer pointer; | 28 typedef typename std::vector<T*>::pointer pointer; |
31 typedef typename std::vector<T*>::const_pointer const_pointer; | 29 typedef typename std::vector<T*>::const_pointer const_pointer; |
32 typedef typename std::vector<T*>::reference reference; | 30 typedef typename std::vector<T*>::reference reference; |
33 typedef typename std::vector<T*>::const_reference const_reference; | 31 typedef typename std::vector<T*>::const_reference const_reference; |
34 typedef typename std::vector<T*>::value_type value_type; | 32 typedef typename std::vector<T*>::value_type value_type; |
35 typedef typename std::vector<T*>::iterator iterator; | 33 typedef typename std::vector<T*>::iterator iterator; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return v_.erase(position); | 133 return v_.erase(position); |
136 } | 134 } |
137 | 135 |
138 // Like |erase()|, but doesn't delete the elements in [first, last). | 136 // Like |erase()|, but doesn't delete the elements in [first, last). |
139 iterator weak_erase(iterator first, iterator last) { | 137 iterator weak_erase(iterator first, iterator last) { |
140 return v_.erase(first, last); | 138 return v_.erase(first, last); |
141 } | 139 } |
142 | 140 |
143 private: | 141 private: |
144 std::vector<T*> v_; | 142 std::vector<T*> v_; |
| 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(ScopedVector); |
145 }; | 145 }; |
146 | 146 |
147 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ | 147 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ |
OLD | NEW |