OLD | NEW |
1 /* Copyright (c) 2006, Google Inc. | 1 /* Copyright (c) 2006, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 21 matching lines...) Expand all Loading... |
32 */ | 32 */ |
33 | 33 |
34 | 34 |
35 #ifndef BASE_STL_ALLOCATOR_H_ | 35 #ifndef BASE_STL_ALLOCATOR_H_ |
36 #define BASE_STL_ALLOCATOR_H_ | 36 #define BASE_STL_ALLOCATOR_H_ |
37 | 37 |
38 #include <config.h> | 38 #include <config.h> |
39 | 39 |
40 #include <stddef.h> // for std::ptrdiff_t | 40 #include <stddef.h> // for std::ptrdiff_t |
41 #include <limits> | 41 #include <limits> |
| 42 #include <cstddef> |
42 | 43 |
43 #include "base/logging.h" | 44 #include "base/logging.h" |
44 | 45 |
45 // Generic allocator class for STL objects | 46 // Generic allocator class for STL objects |
46 // that uses a given type-less allocator Alloc, which must provide: | 47 // that uses a given type-less allocator Alloc, which must provide: |
47 // static void* Alloc::Allocate(size_t size); | 48 // static void* Alloc::Allocate(size_t size); |
48 // static void Alloc::Free(void* ptr, size_t size); | 49 // static void Alloc::Free(void* ptr, size_t size); |
49 // | 50 // |
50 // STL_Allocator<T, MyAlloc> provides the same thread-safety | 51 // STL_Allocator<T, MyAlloc> provides the same thread-safety |
51 // guarantees as MyAlloc. | 52 // guarantees as MyAlloc. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 89 |
89 void construct(pointer p, const T& val) { ::new(p) T(val); } | 90 void construct(pointer p, const T& val) { ::new(p) T(val); } |
90 void construct(pointer p) { ::new(p) T(); } | 91 void construct(pointer p) { ::new(p) T(); } |
91 void destroy(pointer p) { p->~T(); } | 92 void destroy(pointer p) { p->~T(); } |
92 | 93 |
93 // There's no state, so these allocators are always equal | 94 // There's no state, so these allocators are always equal |
94 bool operator==(const STL_Allocator&) const { return true; } | 95 bool operator==(const STL_Allocator&) const { return true; } |
95 }; | 96 }; |
96 | 97 |
97 #endif // BASE_STL_ALLOCATOR_H_ | 98 #endif // BASE_STL_ALLOCATOR_H_ |
OLD | NEW |