Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: cc/base/contiguous_container.h

Issue 2670873002: Remove base's ALIGNOF/ALIGNAS in favor of alignof/alignas. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process/launch_posix.cc ('k') | cc/base/contiguous_container_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « base/process/launch_posix.cc ('k') | cc/base/contiguous_container_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698