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

Side by Side Diff: Source/wtf/Vector.h

Issue 802203004: replace COMPILE_ASSERT with static assert in wtf/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: search/replace fixup Created 6 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 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ++dst; 201 ++dst;
202 } 202 }
203 } 203 }
204 }; 204 };
205 205
206 template<typename T> 206 template<typename T>
207 struct VectorFiller<true, T> 207 struct VectorFiller<true, T>
208 { 208 {
209 static void uninitializedFill(T* dst, T* dstEnd, const T& val) 209 static void uninitializedFill(T* dst, T* dstEnd, const T& val)
210 { 210 {
211 COMPILE_ASSERT(sizeof(T) == sizeof(char), Size_of_type_should_be_equ al_to_one); 211 static_assert(sizeof(T) == sizeof(char), "Size of type should be one ");
212 #if COMPILER(GCC) && defined(_FORTIFY_SOURCE) 212 #if COMPILER(GCC) && defined(_FORTIFY_SOURCE)
213 if (!__builtin_constant_p(dstEnd - dst) || (!(dstEnd - dst))) 213 if (!__builtin_constant_p(dstEnd - dst) || (!(dstEnd - dst)))
214 #endif 214 #endif
215 memset(dst, val, dstEnd - dst); 215 memset(dst, val, dstEnd - dst);
216 } 216 }
217 }; 217 };
218 218
219 template<bool canCompareWithMemcmp, typename T> 219 template<bool canCompareWithMemcmp, typename T>
220 struct VectorComparer; 220 struct VectorComparer;
221 221
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 typedef const T* const_iterator; 591 typedef const T* const_iterator;
592 typedef std::reverse_iterator<iterator> reverse_iterator; 592 typedef std::reverse_iterator<iterator> reverse_iterator;
593 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 593 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
594 594
595 Vector() 595 Vector()
596 { 596 {
597 // Unused slots are initialized to zero so that the visitor and the 597 // Unused slots are initialized to zero so that the visitor and the
598 // finalizer can visit them safely. canInitializeWithMemset tells us 598 // finalizer can visit them safely. canInitializeWithMemset tells us
599 // that the class does not expect matching constructor and 599 // that the class does not expect matching constructor and
600 // destructor calls as long as the memory is zeroed. 600 // destructor calls as long as the memory is zeroed.
601 COMPILE_ASSERT(!Allocator::isGarbageCollected || !VectorTraits<T>::n eedsDestruction || VectorTraits<T>::canInitializeWithMemset, ClassHasProblemsWit hFinalizersCalledOnClearedMemory); 601 static_assert(!Allocator::isGarbageCollected || !VectorTraits<T>::ne edsDestruction || VectorTraits<T>::canInitializeWithMemset, "Class has problems with finalizers called on cleared memory");
602 COMPILE_ASSERT(!WTF::IsPolymorphic<T>::value || !VectorTraits<T>::ca nInitializeWithMemset, CantInitializeWithMemsetIfThereIsAVtable); 602 static_assert(!WTF::IsPolymorphic<T>::value || !VectorTraits<T>::can InitializeWithMemset, "Cant initialize with memset if there is a vtable");
Nico 2014/12/16 17:56:28 "cannot" maybe
Mostyn Bramley-Moore 2014/12/16 19:00:37 Done.
603 m_size = 0; 603 m_size = 0;
604 } 604 }
605 605
606 explicit Vector(size_t size) 606 explicit Vector(size_t size)
607 : Base(size) 607 : Base(size)
608 { 608 {
609 // Unused slots are initialized to zero so that the visitor and the 609 // Unused slots are initialized to zero so that the visitor and the
610 // finalizer can visit them safely. canInitializeWithMemset tells us 610 // finalizer can visit them safely. canInitializeWithMemset tells us
611 // that the class does not expect matching constructor and 611 // that the class does not expect matching constructor and
612 // destructor calls as long as the memory is zeroed. 612 // destructor calls as long as the memory is zeroed.
613 COMPILE_ASSERT(!Allocator::isGarbageCollected || !VectorTraits<T>::n eedsDestruction || VectorTraits<T>::canInitializeWithMemset, ClassHasProblemsWit hFinalizersCalledOnClearedMemory); 613 static_assert(!Allocator::isGarbageCollected || !VectorTraits<T>::ne edsDestruction || VectorTraits<T>::canInitializeWithMemset, "Class has problems with finalizers called on cleared memory");
614 m_size = size; 614 m_size = size;
615 TypeOperations::initialize(begin(), end()); 615 TypeOperations::initialize(begin(), end());
616 } 616 }
617 617
618 // Off-GC-heap vectors: Destructor should be called. 618 // Off-GC-heap vectors: Destructor should be called.
619 // On-GC-heap vectors: Destructor should be called for inline buffers 619 // On-GC-heap vectors: Destructor should be called for inline buffers
620 // (if any) but destructor shouldn't be called for vector backing since 620 // (if any) but destructor shouldn't be called for vector backing since
621 // it is managed by the traced GC heap. 621 // it is managed by the traced GC heap.
622 void finalize() 622 void finalize()
623 { 623 {
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 struct NeedsTracing<Vector<T, N> > { 1228 struct NeedsTracing<Vector<T, N> > {
1229 static const bool value = false; 1229 static const bool value = false;
1230 }; 1230 };
1231 #endif 1231 #endif
1232 1232
1233 } // namespace WTF 1233 } // namespace WTF
1234 1234
1235 using WTF::Vector; 1235 using WTF::Vector;
1236 1236
1237 #endif // WTF_Vector_h 1237 #endif // WTF_Vector_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698