| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CONTIGUOUS_CONTAINER_H_ | 5 #ifndef CC_BASE_CONTIGUOUS_CONTAINER_H_ |
| 6 #define CC_BASE_CONTIGUOUS_CONTAINER_H_ | 6 #define CC_BASE_CONTIGUOUS_CONTAINER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 const BaseElementType& first() const { return *begin(); } | 162 const BaseElementType& first() const { return *begin(); } |
| 163 BaseElementType& last() { return *rbegin(); } | 163 BaseElementType& last() { return *rbegin(); } |
| 164 const BaseElementType& last() const { return *rbegin(); } | 164 const BaseElementType& last() const { return *rbegin(); } |
| 165 BaseElementType& operator[](size_t index) { return *(begin() + index); } | 165 BaseElementType& operator[](size_t index) { return *(begin() + index); } |
| 166 const BaseElementType& operator[](size_t index) const { | 166 const BaseElementType& operator[](size_t index) const { |
| 167 return *(begin() + index); | 167 return *(begin() + index); |
| 168 } | 168 } |
| 169 | 169 |
| 170 template <class DerivedElementType, typename... Args> | 170 template <class DerivedElementType, typename... Args> |
| 171 DerivedElementType& AllocateAndConstruct(Args&&... args) { | 171 DerivedElementType& AllocateAndConstruct(Args&&... args) { |
| 172 static_assert(alignment % ALIGNOF(DerivedElementType) == 0, | 172 static_assert(alignment % alignof(DerivedElementType) == 0, |
| 173 "Derived type requires stronger alignment."); | 173 "Derived type requires stronger alignment."); |
| 174 return *new (AlignedAllocate(sizeof(DerivedElementType))) | 174 return *new (AlignedAllocate(sizeof(DerivedElementType))) |
| 175 DerivedElementType(std::forward<Args>(args)...); | 175 DerivedElementType(std::forward<Args>(args)...); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void RemoveLast() { | 178 void RemoveLast() { |
| 179 DCHECK(!empty()); | 179 DCHECK(!empty()); |
| 180 last().~BaseElementType(); | 180 last().~BaseElementType(); |
| 181 ContiguousContainerBase::RemoveLast(); | 181 ContiguousContainerBase::RemoveLast(); |
| 182 } | 182 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 DCHECK_EQ(aligned_size % alignment, 0u); | 216 DCHECK_EQ(aligned_size % alignment, 0u); |
| 217 DCHECK_GE(aligned_size, size); | 217 DCHECK_GE(aligned_size, size); |
| 218 DCHECK_LT(aligned_size, size + alignment); | 218 DCHECK_LT(aligned_size, size + alignment); |
| 219 return aligned_size; | 219 return aligned_size; |
| 220 } | 220 } |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 } // namespace cc | 223 } // namespace cc |
| 224 | 224 |
| 225 #endif // CC_BASE_CONTIGUOUS_CONTAINER_H_ | 225 #endif // CC_BASE_CONTIGUOUS_CONTAINER_H_ |
| OLD | NEW |