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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 template<typename P> | 68 template<typename P> |
69 struct VectorTraits<RefPtr<P> > : SimpleClassVectorTraits<RefPtr<P> > { }; | 69 struct VectorTraits<RefPtr<P> > : SimpleClassVectorTraits<RefPtr<P> > { }; |
70 | 70 |
71 template<typename P> | 71 template<typename P> |
72 struct VectorTraits<OwnPtr<P> > : SimpleClassVectorTraits<OwnPtr<P> > { | 72 struct VectorTraits<OwnPtr<P> > : SimpleClassVectorTraits<OwnPtr<P> > { |
73 // OwnPtr -> PassOwnPtr has a very particular structure that | 73 // OwnPtr -> PassOwnPtr has a very particular structure that |
74 // tricks the normal type traits into thinking that the class | 74 // tricks the normal type traits into thinking that the class |
75 // is "trivially copyable". | 75 // is "trivially copyable". |
76 static const bool canCopyWithMemcpy = false; | 76 static const bool canCopyWithMemcpy = false; |
77 }; | 77 }; |
78 COMPILE_ASSERT(VectorTraits<RefPtr<int> >::canInitializeWithMemset, ineffici
entRefPtrVector); | 78 static_assert(VectorTraits<RefPtr<int>>::canInitializeWithMemset, "inefficie
nt RefPtr Vector"); |
79 COMPILE_ASSERT(VectorTraits<RefPtr<int> >::canMoveWithMemcpy, inefficientRef
PtrVector); | 79 static_assert(VectorTraits<RefPtr<int>>::canMoveWithMemcpy, "inefficient Ref
Ptr Vector"); |
80 COMPILE_ASSERT(VectorTraits<RefPtr<int> >::canCompareWithMemcmp, inefficient
RefPtrVector); | 80 static_assert(VectorTraits<RefPtr<int>>::canCompareWithMemcmp, "inefficient
RefPtr Vector"); |
81 COMPILE_ASSERT(VectorTraits<OwnPtr<int> >::canInitializeWithMemset, ineffici
entOwnPtrVector); | 81 static_assert(VectorTraits<OwnPtr<int>>::canInitializeWithMemset, "inefficie
nt OwnPtr Vector"); |
82 COMPILE_ASSERT(VectorTraits<OwnPtr<int> >::canMoveWithMemcpy, inefficientOwn
PtrVector); | 82 static_assert(VectorTraits<OwnPtr<int>>::canMoveWithMemcpy, "inefficient Own
Ptr Vector"); |
83 COMPILE_ASSERT(VectorTraits<OwnPtr<int> >::canCompareWithMemcmp, inefficient
OwnPtrVector); | 83 static_assert(VectorTraits<OwnPtr<int>>::canCompareWithMemcmp, "inefficient
OwnPtr Vector"); |
84 | 84 |
85 template<typename First, typename Second> | 85 template<typename First, typename Second> |
86 struct VectorTraits<pair<First, Second> > | 86 struct VectorTraits<pair<First, Second> > |
87 { | 87 { |
88 typedef VectorTraits<First> FirstTraits; | 88 typedef VectorTraits<First> FirstTraits; |
89 typedef VectorTraits<Second> SecondTraits; | 89 typedef VectorTraits<Second> SecondTraits; |
90 | 90 |
91 static const bool needsDestruction = FirstTraits::needsDestruction || Se
condTraits::needsDestruction; | 91 static const bool needsDestruction = FirstTraits::needsDestruction || Se
condTraits::needsDestruction; |
92 static const bool canInitializeWithMemset = FirstTraits::canInitializeWi
thMemset && SecondTraits::canInitializeWithMemset; | 92 static const bool canInitializeWithMemset = FirstTraits::canInitializeWi
thMemset && SecondTraits::canInitializeWithMemset; |
93 static const bool canMoveWithMemcpy = FirstTraits::canMoveWithMemcpy &&
SecondTraits::canMoveWithMemcpy; | 93 static const bool canMoveWithMemcpy = FirstTraits::canMoveWithMemcpy &&
SecondTraits::canMoveWithMemcpy; |
94 static const bool canCopyWithMemcpy = FirstTraits::canCopyWithMemcpy &&
SecondTraits::canCopyWithMemcpy; | 94 static const bool canCopyWithMemcpy = FirstTraits::canCopyWithMemcpy &&
SecondTraits::canCopyWithMemcpy; |
95 static const bool canFillWithMemset = false; | 95 static const bool canFillWithMemset = false; |
96 static const bool canCompareWithMemcmp = FirstTraits::canCompareWithMemc
mp && SecondTraits::canCompareWithMemcmp; | 96 static const bool canCompareWithMemcmp = FirstTraits::canCompareWithMemc
mp && SecondTraits::canCompareWithMemcmp; |
97 template <typename U = void> | 97 template <typename U = void> |
98 struct NeedsTracingLazily { | 98 struct NeedsTracingLazily { |
99 static const bool value = ShouldBeTraced<FirstTraits>::value || Shou
ldBeTraced<SecondTraits>::value; | 99 static const bool value = ShouldBeTraced<FirstTraits>::value || Shou
ldBeTraced<SecondTraits>::value; |
100 }; | 100 }; |
101 static const WeakHandlingFlag weakHandlingFlag = NoWeakHandlingInCollect
ions; // We don't support weak handling in vectors. | 101 static const WeakHandlingFlag weakHandlingFlag = NoWeakHandlingInCollect
ions; // We don't support weak handling in vectors. |
102 }; | 102 }; |
103 | 103 |
104 } // namespace WTF | 104 } // namespace WTF |
105 | 105 |
106 #define WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(ClassName) \ | 106 #define WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(ClassName) \ |
107 namespace WTF { \ | 107 namespace WTF { \ |
108 COMPILE_ASSERT(!IsTriviallyDefaultConstructible<ClassName>::value || !IsTriviall
yCopyAssignable<ClassName>::value, macro_not_needed); \ | 108 static_assert(!IsTriviallyDefaultConstructible<ClassName>::value || !IsTrivially
CopyAssignable<ClassName>::value, "macro not needed"); \ |
109 template<> \ | 109 template<> \ |
110 struct VectorTraits<ClassName> : SimpleClassVectorTraits<ClassName> { }; \ | 110 struct VectorTraits<ClassName> : SimpleClassVectorTraits<ClassName> { }; \ |
111 } | 111 } |
112 | 112 |
113 #define WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(ClassName) \ | 113 #define WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(ClassName) \ |
114 namespace WTF { \ | 114 namespace WTF { \ |
115 COMPILE_ASSERT(!WTF::IsTriviallyDefaultConstructible<ClassName>::value || !IsTri
viallyCopyAssignable<ClassName>::value, macro_not_needed); \ | 115 static_assert(!WTF::IsTriviallyDefaultConstructible<ClassName>::value || !IsTriv
iallyCopyAssignable<ClassName>::value, "macro not needed"); \ |
116 template<> \ | 116 template<> \ |
117 struct VectorTraits<ClassName> : VectorTraitsBase<ClassName> \ | 117 struct VectorTraits<ClassName> : VectorTraitsBase<ClassName> \ |
118 { \ | 118 { \ |
119 static const bool canInitializeWithMemset = true; \ | 119 static const bool canInitializeWithMemset = true; \ |
120 static const bool canMoveWithMemcpy = true; \ | 120 static const bool canMoveWithMemcpy = true; \ |
121 }; \ | 121 }; \ |
122 } | 122 } |
123 | 123 |
124 #define WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(ClassName) \ | 124 #define WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(ClassName) \ |
125 namespace WTF { \ | 125 namespace WTF { \ |
126 COMPILE_ASSERT(!WTF::IsTriviallyDefaultConstructible<ClassName>::value, macro_no
t_needed); \ | 126 static_assert(!WTF::IsTriviallyDefaultConstructible<ClassName>::value, "macro no
t needed"); \ |
127 template<> \ | 127 template<> \ |
128 struct VectorTraits<ClassName> : VectorTraitsBase<ClassName> \ | 128 struct VectorTraits<ClassName> : VectorTraitsBase<ClassName> \ |
129 { \ | 129 { \ |
130 static const bool canInitializeWithMemset = true; \ | 130 static const bool canInitializeWithMemset = true; \ |
131 }; \ | 131 }; \ |
132 } | 132 } |
133 | 133 |
134 using WTF::VectorTraits; | 134 using WTF::VectorTraits; |
135 using WTF::SimpleClassVectorTraits; | 135 using WTF::SimpleClassVectorTraits; |
136 | 136 |
137 #endif // WTF_VectorTraits_h | 137 #endif // WTF_VectorTraits_h |
OLD | NEW |