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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 { | 59 { |
60 static const bool canInitializeWithMemset = true; | 60 static const bool canInitializeWithMemset = true; |
61 static const bool canMoveWithMemcpy = true; | 61 static const bool canMoveWithMemcpy = true; |
62 static const bool canCompareWithMemcmp = true; | 62 static const bool canCompareWithMemcmp = true; |
63 }; | 63 }; |
64 | 64 |
65 // We know OwnPtr and RefPtr are simple enough that initializing to 0 and | 65 // We know OwnPtr and RefPtr are simple enough that initializing to 0 and |
66 // moving with memcpy (and then not destructing the original) will totally | 66 // moving with memcpy (and then not destructing the original) will totally |
67 // work. | 67 // work. |
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 static_assert(VectorTraits<RefPtr<int>>::canInitializeWithMemset, "inefficie
nt RefPtr Vector"); | 78 static_assert(VectorTraits<RefPtr<int>>::canInitializeWithMemset, "inefficie
nt RefPtr Vector"); |
79 static_assert(VectorTraits<RefPtr<int>>::canMoveWithMemcpy, "inefficient Ref
Ptr Vector"); | 79 static_assert(VectorTraits<RefPtr<int>>::canMoveWithMemcpy, "inefficient Ref
Ptr Vector"); |
80 static_assert(VectorTraits<RefPtr<int>>::canCompareWithMemcmp, "inefficient
RefPtr Vector"); | 80 static_assert(VectorTraits<RefPtr<int>>::canCompareWithMemcmp, "inefficient
RefPtr Vector"); |
81 static_assert(VectorTraits<OwnPtr<int>>::canInitializeWithMemset, "inefficie
nt OwnPtr Vector"); | 81 static_assert(VectorTraits<OwnPtr<int>>::canInitializeWithMemset, "inefficie
nt OwnPtr Vector"); |
82 static_assert(VectorTraits<OwnPtr<int>>::canMoveWithMemcpy, "inefficient Own
Ptr Vector"); | 82 static_assert(VectorTraits<OwnPtr<int>>::canMoveWithMemcpy, "inefficient Own
Ptr Vector"); |
83 static_assert(VectorTraits<OwnPtr<int>>::canCompareWithMemcmp, "inefficient
OwnPtr Vector"); | 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; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |