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_CONTAINERS_STACK_CONTAINER_H_ | 5 #ifndef BASE_CONTAINERS_STACK_CONTAINER_H_ |
6 #define BASE_CONTAINERS_STACK_CONTAINER_H_ | 6 #define BASE_CONTAINERS_STACK_CONTAINER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/aligned_memory.h" |
| 13 #include "base/strings/string16.h" |
12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
13 #include "base/memory/aligned_memory.h" | |
14 #include "base/string16.h" | |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 // This allocator can be used with STL containers to provide a stack buffer | 18 // This allocator can be used with STL containers to provide a stack buffer |
19 // from which to allocate memory and overflows onto the heap. This stack buffer | 19 // from which to allocate memory and overflows onto the heap. This stack buffer |
20 // would be allocated on the stack and allows us to avoid heap operations in | 20 // would be allocated on the stack and allows us to avoid heap operations in |
21 // some situations. | 21 // some situations. |
22 // | 22 // |
23 // STL likes to make copies of allocators, so the allocator itself can't hold | 23 // STL likes to make copies of allocators, so the allocator itself can't hold |
24 // the data. Instead, we make the creator responsible for creating a | 24 // the data. Instead, we make the creator responsible for creating a |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // operator-> (using "->at()" does exception stuff we don't want). | 249 // operator-> (using "->at()" does exception stuff we don't want). |
250 T& operator[](size_t i) { return this->container().operator[](i); } | 250 T& operator[](size_t i) { return this->container().operator[](i); } |
251 const T& operator[](size_t i) const { | 251 const T& operator[](size_t i) const { |
252 return this->container().operator[](i); | 252 return this->container().operator[](i); |
253 } | 253 } |
254 }; | 254 }; |
255 | 255 |
256 } // namespace base | 256 } // namespace base |
257 | 257 |
258 #endif // BASE_CONTAINERS_STACK_CONTAINER_H_ | 258 #endif // BASE_CONTAINERS_STACK_CONTAINER_H_ |
OLD | NEW |