Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_BASE_SCOPED_PTR_VECTOR_H_ | 5 #ifndef CC_BASE_SCOPED_PTR_VECTOR_H_ |
| 6 #define CC_BASE_SCOPED_PTR_VECTOR_H_ | 6 #define CC_BASE_SCOPED_PTR_VECTOR_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 // This type acts like a vector<scoped_ptr> based on top of std::vector. The | 18 // This type acts like a vector<scoped_ptr> based on top of std::vector. The |
| 19 // ScopedPtrVector has ownership of all elements in the vector. | 19 // ScopedPtrVector has ownership of all elements in the vector. |
| 20 template <typename T> | 20 template <typename T> |
| 21 class ScopedPtrVector { | 21 class ScopedPtrVector { |
| 22 public: | 22 public: |
| 23 typedef typename std::vector<T*>::const_iterator const_iterator; | 23 typedef typename std::vector<const T*>::const_iterator const_iterator; |
| 24 typedef typename std::vector<T*>::reverse_iterator reverse_iterator; | 24 typedef typename std::vector<T*>::reverse_iterator reverse_iterator; |
| 25 typedef typename std::vector<T*>::const_reverse_iterator | 25 typedef typename std::vector<T*>::const_reverse_iterator |
|
jamesr
2014/07/24 19:55:47
this one too?
| |
| 26 const_reverse_iterator; | 26 const_reverse_iterator; |
| 27 | 27 |
| 28 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
| 29 // On Android the iterator is not a class, so we can't block assignment. | 29 // On Android the iterator is not a class, so we can't block assignment. |
| 30 typedef typename std::vector<T*>::iterator iterator; | 30 typedef typename std::vector<T*>::iterator iterator; |
| 31 #else | 31 #else |
| 32 // Ban setting values on the iterator directly. New pointers must be passed | 32 // Ban setting values on the iterator directly. New pointers must be passed |
| 33 // to methods on the ScopedPtrVector class to appear in the vector. | 33 // to methods on the ScopedPtrVector class to appear in the vector. |
| 34 class iterator : public std::vector<T*>::iterator { | 34 class iterator : public std::vector<T*>::iterator { |
| 35 public: | 35 public: |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 | 178 |
| 179 private: | 179 private: |
| 180 std::vector<T*> data_; | 180 std::vector<T*> data_; |
| 181 | 181 |
| 182 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); | 182 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 } // namespace cc | 185 } // namespace cc |
| 186 | 186 |
| 187 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_ | 187 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_ |
| OLD | NEW |