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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ContiguousContainer.h

Issue 1477213003: More switching to standard type traits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use std::is_base_of Created 5 years 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
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 ContiguousContainer_h 5 #ifndef ContiguousContainer_h
6 #define ContiguousContainer_h 6 #define ContiguousContainer_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "wtf/Alignment.h" 9 #include "wtf/Alignment.h"
10 #include "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 BaseElementType& first() { return *begin(); } 139 BaseElementType& first() { return *begin(); }
140 const BaseElementType& first() const { return *begin(); } 140 const BaseElementType& first() const { return *begin(); }
141 BaseElementType& last() { return *rbegin(); } 141 BaseElementType& last() { return *rbegin(); }
142 const BaseElementType& last() const { return *rbegin(); } 142 const BaseElementType& last() const { return *rbegin(); }
143 BaseElementType& operator[](size_t index) { return *(begin() + index); } 143 BaseElementType& operator[](size_t index) { return *(begin() + index); }
144 const BaseElementType& operator[](size_t index) const { return *(begin() + i ndex); } 144 const BaseElementType& operator[](size_t index) const { return *(begin() + i ndex); }
145 145
146 template <class DerivedElementType, typename... Args> 146 template <class DerivedElementType, typename... Args>
147 DerivedElementType& allocateAndConstruct(Args&&... args) 147 DerivedElementType& allocateAndConstruct(Args&&... args)
148 { 148 {
149 static_assert(WTF::IsSubclass<DerivedElementType, BaseElementType>::valu e, 149 static_assert(std::is_base_of<BaseElementType, DerivedElementType>::valu e,
150 "Must use subclass of BaseElementType."); 150 "Must use subclass of BaseElementType.");
151 static_assert(alignment % WTF_ALIGN_OF(DerivedElementType) == 0, 151 static_assert(alignment % WTF_ALIGN_OF(DerivedElementType) == 0,
152 "Derived type requires stronger alignment."); 152 "Derived type requires stronger alignment.");
153 size_t allocSize = align(sizeof(DerivedElementType)); 153 size_t allocSize = align(sizeof(DerivedElementType));
154 return *new (allocate(allocSize, WTF_HEAP_PROFILER_TYPE_NAME(DerivedElem entType))) DerivedElementType(WTF::forward<Args>(args)...); 154 return *new (allocate(allocSize, WTF_HEAP_PROFILER_TYPE_NAME(DerivedElem entType))) DerivedElementType(WTF::forward<Args>(args)...);
155 } 155 }
156 156
157 void removeLast() 157 void removeLast()
158 { 158 {
159 ASSERT(!isEmpty()); 159 ASSERT(!isEmpty());
(...skipping 30 matching lines...) Expand all
190 ASSERT(alignedSize % alignment == 0); 190 ASSERT(alignedSize % alignment == 0);
191 ASSERT(alignedSize >= size); 191 ASSERT(alignedSize >= size);
192 ASSERT(alignedSize < size + alignment); 192 ASSERT(alignedSize < size + alignment);
193 return alignedSize; 193 return alignedSize;
194 } 194 }
195 }; 195 };
196 196
197 } // namespace blink 197 } // namespace blink
198 198
199 #endif // ContiguousContainer_h 199 #endif // ContiguousContainer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698