OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 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 30 matching lines...) Expand all Loading... |
41 // destructor can be invoked over. The zero'ed value representing an unused | 41 // destructor can be invoked over. The zero'ed value representing an unused |
42 // slot in the vector's backing storage; it does not have to be equal to | 42 // slot in the vector's backing storage; it does not have to be equal to |
43 // what its constructor(s) would create, only be valid for those two uses. | 43 // what its constructor(s) would create, only be valid for those two uses. |
44 static const bool canClearUnusedSlotsWithMemset = IsTriviallyDefaultConstruc
tible<T>::value; | 44 static const bool canClearUnusedSlotsWithMemset = IsTriviallyDefaultConstruc
tible<T>::value; |
45 | 45 |
46 static const bool canMoveWithMemcpy = IsTriviallyMoveAssignable<T>::value; | 46 static const bool canMoveWithMemcpy = IsTriviallyMoveAssignable<T>::value; |
47 static const bool canCopyWithMemcpy = IsTriviallyCopyAssignable<T>::value; | 47 static const bool canCopyWithMemcpy = IsTriviallyCopyAssignable<T>::value; |
48 static const bool canFillWithMemset = IsTriviallyDefaultConstructible<T>::va
lue && (sizeof(T) == sizeof(char)); | 48 static const bool canFillWithMemset = IsTriviallyDefaultConstructible<T>::va
lue && (sizeof(T) == sizeof(char)); |
49 static const bool canCompareWithMemcmp = std::is_scalar<T>::value; // Types
without padding. | 49 static const bool canCompareWithMemcmp = std::is_scalar<T>::value; // Types
without padding. |
50 template <typename U = void> | 50 template <typename U = void> |
51 struct NeedsTracingLazily { | 51 struct IsTraceableInCollection { |
52 static const bool value = NeedsTracing<T>::value; | 52 static const bool value = IsTraceable<T>::value; |
53 }; | 53 }; |
54 static const WeakHandlingFlag weakHandlingFlag = NoWeakHandlingInCollections
; // We don't support weak handling in vectors. | 54 static const WeakHandlingFlag weakHandlingFlag = NoWeakHandlingInCollections
; // We don't support weak handling in vectors. |
55 }; | 55 }; |
56 | 56 |
57 template <typename T> | 57 template <typename T> |
58 struct VectorTraits : VectorTraitsBase<T> {}; | 58 struct VectorTraits : VectorTraitsBase<T> {}; |
59 | 59 |
60 // Classes marked with SimpleVectorTraits will use memmov, memcpy, memcmp | 60 // Classes marked with SimpleVectorTraits will use memmov, memcpy, memcmp |
61 // instead of constructors, copy operators, etc for initialization, move and | 61 // instead of constructors, copy operators, etc for initialization, move and |
62 // comparison. | 62 // comparison. |
(...skipping 29 matching lines...) Expand all Loading... |
92 typedef VectorTraits<Second> SecondTraits; | 92 typedef VectorTraits<Second> SecondTraits; |
93 | 93 |
94 static const bool needsDestruction = FirstTraits::needsDestruction || Second
Traits::needsDestruction; | 94 static const bool needsDestruction = FirstTraits::needsDestruction || Second
Traits::needsDestruction; |
95 static const bool canInitializeWithMemset = FirstTraits::canInitializeWithMe
mset && SecondTraits::canInitializeWithMemset; | 95 static const bool canInitializeWithMemset = FirstTraits::canInitializeWithMe
mset && SecondTraits::canInitializeWithMemset; |
96 static const bool canMoveWithMemcpy = FirstTraits::canMoveWithMemcpy && Seco
ndTraits::canMoveWithMemcpy; | 96 static const bool canMoveWithMemcpy = FirstTraits::canMoveWithMemcpy && Seco
ndTraits::canMoveWithMemcpy; |
97 static const bool canCopyWithMemcpy = FirstTraits::canCopyWithMemcpy && Seco
ndTraits::canCopyWithMemcpy; | 97 static const bool canCopyWithMemcpy = FirstTraits::canCopyWithMemcpy && Seco
ndTraits::canCopyWithMemcpy; |
98 static const bool canFillWithMemset = false; | 98 static const bool canFillWithMemset = false; |
99 static const bool canCompareWithMemcmp = FirstTraits::canCompareWithMemcmp &
& SecondTraits::canCompareWithMemcmp; | 99 static const bool canCompareWithMemcmp = FirstTraits::canCompareWithMemcmp &
& SecondTraits::canCompareWithMemcmp; |
100 static const bool canClearUnusedSlotsWithMemset = FirstTraits::canClearUnuse
dSlotsWithMemset && SecondTraits::canClearUnusedSlotsWithMemset; | 100 static const bool canClearUnusedSlotsWithMemset = FirstTraits::canClearUnuse
dSlotsWithMemset && SecondTraits::canClearUnusedSlotsWithMemset; |
101 template <typename U = void> | 101 template <typename U = void> |
102 struct NeedsTracingLazily { | 102 struct IsTraceableInCollection { |
103 static const bool value = NeedsTracingTrait<FirstTraits>::value || Needs
TracingTrait<SecondTraits>::value; | 103 static const bool value = IsTraceableInCollectionTrait<FirstTraits>::val
ue || IsTraceableInCollectionTrait<SecondTraits>::value; |
104 }; | 104 }; |
105 static const WeakHandlingFlag weakHandlingFlag = NoWeakHandlingInCollections
; // We don't support weak handling in vectors. | 105 static const WeakHandlingFlag weakHandlingFlag = NoWeakHandlingInCollections
; // We don't support weak handling in vectors. |
106 }; | 106 }; |
107 | 107 |
108 } // namespace WTF | 108 } // namespace WTF |
109 | 109 |
110 #define WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(ClassName) \ | 110 #define WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(ClassName) \ |
111 namespace WTF { \ | 111 namespace WTF { \ |
112 static_assert(!IsTriviallyDefaultConstructible<ClassName>::value || !IsTrivially
MoveAssignable<ClassName>::value || !std::is_scalar<ClassName>::value, "macro no
t needed"); \ | 112 static_assert(!IsTriviallyDefaultConstructible<ClassName>::value || !IsTrivially
MoveAssignable<ClassName>::value || !std::is_scalar<ClassName>::value, "macro no
t needed"); \ |
113 template <> \ | 113 template <> \ |
(...skipping 30 matching lines...) Expand all Loading... |
144 struct VectorTraits<ClassName> : VectorTraitsBase<ClassName> \ | 144 struct VectorTraits<ClassName> : VectorTraitsBase<ClassName> \ |
145 { \ | 145 { \ |
146 static const bool canClearUnusedSlotsWithMemset = true; \ | 146 static const bool canClearUnusedSlotsWithMemset = true; \ |
147 }; \ | 147 }; \ |
148 } | 148 } |
149 | 149 |
150 using WTF::VectorTraits; | 150 using WTF::VectorTraits; |
151 using WTF::SimpleClassVectorTraits; | 151 using WTF::SimpleClassVectorTraits; |
152 | 152 |
153 #endif // WTF_VectorTraits_h | 153 #endif // WTF_VectorTraits_h |
OLD | NEW |