| 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 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "TypeTraits.h" | 23 #include "TypeTraits.h" |
| 24 | 24 |
| 25 #include "Assertions.h" | 25 #include "Assertions.h" |
| 26 #include "Noncopyable.h" | 26 #include "Noncopyable.h" |
| 27 | 27 |
| 28 namespace WTF { | 28 namespace WTF { |
| 29 | 29 |
| 30 COMPILE_ASSERT(IsInteger<bool>::value, WTF_IsInteger_bool_true); | 30 static_assert(IsInteger<bool>::value, "WTF_IsInteger_bool_true"); |
| 31 COMPILE_ASSERT(IsInteger<char>::value, WTF_IsInteger_char_true); | 31 static_assert(IsInteger<char>::value, "WTF_IsInteger_char_true"); |
| 32 COMPILE_ASSERT(IsInteger<signed char>::value, WTF_IsInteger_signed_char_true); | 32 static_assert(IsInteger<signed char>::value, "WTF_IsInteger_signed_char_true"); |
| 33 COMPILE_ASSERT(IsInteger<unsigned char>::value, WTF_IsInteger_unsigned_char_true
); | 33 static_assert(IsInteger<unsigned char>::value, "WTF_IsInteger_unsigned_char_true
"); |
| 34 COMPILE_ASSERT(IsInteger<short>::value, WTF_IsInteger_short_true); | 34 static_assert(IsInteger<short>::value, "WTF_IsInteger_short_true"); |
| 35 COMPILE_ASSERT(IsInteger<unsigned short>::value, WTF_IsInteger_unsigned_short_tr
ue); | 35 static_assert(IsInteger<unsigned short>::value, "WTF_IsInteger_unsigned_short_tr
ue"); |
| 36 COMPILE_ASSERT(IsInteger<int>::value, WTF_IsInteger_int_true); | 36 static_assert(IsInteger<int>::value, "WTF_IsInteger_int_true"); |
| 37 COMPILE_ASSERT(IsInteger<unsigned>::value, WTF_IsInteger_unsigned_int_true); | 37 static_assert(IsInteger<unsigned>::value, "WTF_IsInteger_unsigned_int_true"); |
| 38 COMPILE_ASSERT(IsInteger<long>::value, WTF_IsInteger_long_true); | 38 static_assert(IsInteger<long>::value, "WTF_IsInteger_long_true"); |
| 39 COMPILE_ASSERT(IsInteger<unsigned long>::value, WTF_IsInteger_unsigned_long_true
); | 39 static_assert(IsInteger<unsigned long>::value, "WTF_IsInteger_unsigned_long_true
"); |
| 40 COMPILE_ASSERT(IsInteger<long long>::value, WTF_IsInteger_long_long_true); | 40 static_assert(IsInteger<long long>::value, "WTF_IsInteger_long_long_true"); |
| 41 COMPILE_ASSERT(IsInteger<unsigned long long>::value, WTF_IsInteger_unsigned_long
_long_true); | 41 static_assert(IsInteger<unsigned long long>::value, "WTF_IsInteger_unsigned_long
_long_true"); |
| 42 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) | 42 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) |
| 43 COMPILE_ASSERT(IsInteger<wchar_t>::value, WTF_IsInteger_wchar_t_true); | 43 static_assert(IsInteger<wchar_t>::value, "WTF_IsInteger_wchar_t_true"); |
| 44 #endif | 44 #endif |
| 45 COMPILE_ASSERT(!IsInteger<char*>::value, WTF_IsInteger_char_pointer_false); | 45 static_assert(!IsInteger<char*>::value, "WTF_IsInteger_char_pointer_false"); |
| 46 COMPILE_ASSERT(!IsInteger<const char*>::value, WTF_IsInteger_const_char_pointer_
false); | 46 static_assert(!IsInteger<const char*>::value, "WTF_IsInteger_const_char_pointer_
false"); |
| 47 COMPILE_ASSERT(!IsInteger<volatile char*>::value, WTF_IsInteger_volatile_char_po
inter_false); | 47 static_assert(!IsInteger<volatile char*>::value, "WTF_IsInteger_volatile_char_po
inter_false"); |
| 48 COMPILE_ASSERT(!IsInteger<double>::value, WTF_IsInteger_double_false); | 48 static_assert(!IsInteger<double>::value, "WTF_IsInteger_double_false"); |
| 49 COMPILE_ASSERT(!IsInteger<float>::value, WTF_IsInteger_float_false); | 49 static_assert(!IsInteger<float>::value, "WTF_IsInteger_float_false"); |
| 50 | 50 |
| 51 COMPILE_ASSERT(IsFloatingPoint<float>::value, WTF_IsFloatingPoint_float_true); | 51 static_assert(IsFloatingPoint<float>::value, "WTF_IsFloatingPoint_float_true"); |
| 52 COMPILE_ASSERT(IsFloatingPoint<double>::value, WTF_IsFloatingPoint_double_true); | 52 static_assert(IsFloatingPoint<double>::value, "WTF_IsFloatingPoint_double_true")
; |
| 53 COMPILE_ASSERT(IsFloatingPoint<long double>::value, WTF_IsFloatingPoint_long_dou
ble_true); | 53 static_assert(IsFloatingPoint<long double>::value, "WTF_IsFloatingPoint_long_dou
ble_true"); |
| 54 COMPILE_ASSERT(!IsFloatingPoint<int>::value, WTF_IsFloatingPoint_int_false); | 54 static_assert(!IsFloatingPoint<int>::value, "WTF_IsFloatingPoint_int_false"); |
| 55 | 55 |
| 56 COMPILE_ASSERT(IsPointer<void*>::value, WTF_IsPointer_void_star_true); | 56 static_assert(IsPointer<void*>::value, "WTF_IsPointer_void_star_true"); |
| 57 COMPILE_ASSERT(IsPointer<char*>::value, WTF_IsPointer_char_star_true); | 57 static_assert(IsPointer<char*>::value, "WTF_IsPointer_char_star_true"); |
| 58 COMPILE_ASSERT(IsPointer<const char*>::value, WTF_IsPointer_const_char_star_true
); | 58 static_assert(IsPointer<const char*>::value, "WTF_IsPointer_const_char_star_true
"); |
| 59 COMPILE_ASSERT(!IsPointer<char>::value, WTF_IsPointer_char_false); | 59 static_assert(!IsPointer<char>::value, "WTF_IsPointer_char_false"); |
| 60 COMPILE_ASSERT(!IsPointer<int>::value, WTF_IsPointer_int_false); | 60 static_assert(!IsPointer<int>::value, "WTF_IsPointer_int_false"); |
| 61 COMPILE_ASSERT(!IsPointer<long>::value, WTF_IsPointer_long_false); | 61 static_assert(!IsPointer<long>::value, "WTF_IsPointer_long_false"); |
| 62 | 62 |
| 63 enum TestEnum { TestEnumValue }; | 63 enum TestEnum { TestEnumValue }; |
| 64 COMPILE_ASSERT(IsEnum<TestEnum>::value, WTF_IsEnum_enum_true); | 64 static_assert(IsEnum<TestEnum>::value, "WTF_IsEnum_enum_true"); |
| 65 COMPILE_ASSERT(!IsEnum<int>::value, WTF_IsEnum_int_false); | 65 static_assert(!IsEnum<int>::value, "WTF_IsEnum_int_false"); |
| 66 COMPILE_ASSERT(!IsEnum<TestEnum*>::value, WTF_IsEnum_enum_star_false); | 66 static_assert(!IsEnum<TestEnum*>::value, "WTF_IsEnum_enum_star_false"); |
| 67 | 67 |
| 68 COMPILE_ASSERT(IsScalar<TestEnum>::value, WTF_IsScalar_enum_true); | 68 static_assert(IsScalar<TestEnum>::value, "WTF_IsScalar_enum_true"); |
| 69 COMPILE_ASSERT(IsScalar<int>::value, WTF_IsScalar_int_true); | 69 static_assert(IsScalar<int>::value, "WTF_IsScalar_int_true"); |
| 70 COMPILE_ASSERT(IsScalar<TestEnum*>::value, WTF_IsScalar_enum_star_true); | 70 static_assert(IsScalar<TestEnum*>::value, "WTF_IsScalar_enum_star_true"); |
| 71 COMPILE_ASSERT(IsScalar<double>::value, WTF_IsScalar_double_true); | 71 static_assert(IsScalar<double>::value, "WTF_IsScalar_double_true"); |
| 72 | 72 |
| 73 COMPILE_ASSERT(IsPod<bool>::value, WTF_IsPod_bool_true); | 73 static_assert(IsPod<bool>::value, "WTF_IsPod_bool_true"); |
| 74 COMPILE_ASSERT(IsPod<char>::value, WTF_IsPod_char_true); | 74 static_assert(IsPod<char>::value, "WTF_IsPod_char_true"); |
| 75 COMPILE_ASSERT(IsPod<signed char>::value, WTF_IsPod_signed_char_true); | 75 static_assert(IsPod<signed char>::value, "WTF_IsPod_signed_char_true"); |
| 76 COMPILE_ASSERT(IsPod<unsigned char>::value, WTF_IsPod_unsigned_char_true); | 76 static_assert(IsPod<unsigned char>::value, "WTF_IsPod_unsigned_char_true"); |
| 77 COMPILE_ASSERT(IsPod<short>::value, WTF_IsPod_short_true); | 77 static_assert(IsPod<short>::value, "WTF_IsPod_short_true"); |
| 78 COMPILE_ASSERT(IsPod<unsigned short>::value, WTF_IsPod_unsigned_short_true); | 78 static_assert(IsPod<unsigned short>::value, "WTF_IsPod_unsigned_short_true"); |
| 79 COMPILE_ASSERT(IsPod<int>::value, WTF_IsPod_int_true); | 79 static_assert(IsPod<int>::value, "WTF_IsPod_int_true"); |
| 80 COMPILE_ASSERT(IsPod<unsigned>::value, WTF_IsPod_unsigned_int_true); | 80 static_assert(IsPod<unsigned>::value, "WTF_IsPod_unsigned_int_true"); |
| 81 COMPILE_ASSERT(IsPod<long>::value, WTF_IsPod_long_true); | 81 static_assert(IsPod<long>::value, "WTF_IsPod_long_true"); |
| 82 COMPILE_ASSERT(IsPod<unsigned long>::value, WTF_IsPod_unsigned_long_true); | 82 static_assert(IsPod<unsigned long>::value, "WTF_IsPod_unsigned_long_true"); |
| 83 COMPILE_ASSERT(IsPod<long long>::value, WTF_IsPod_long_long_true); | 83 static_assert(IsPod<long long>::value, "WTF_IsPod_long_long_true"); |
| 84 COMPILE_ASSERT(IsPod<unsigned long long>::value, WTF_IsPod_unsigned_long_long_tr
ue); | 84 static_assert(IsPod<unsigned long long>::value, "WTF_IsPod_unsigned_long_long_tr
ue"); |
| 85 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) | 85 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) |
| 86 COMPILE_ASSERT(IsPod<wchar_t>::value, WTF_IsPod_wchar_t_true); | 86 static_assert(IsPod<wchar_t>::value, "WTF_IsPod_wchar_t_true"); |
| 87 #endif | 87 #endif |
| 88 COMPILE_ASSERT(IsPod<char*>::value, WTF_IsPod_char_pointer_true); | 88 static_assert(IsPod<char*>::value, "WTF_IsPod_char_pointer_true"); |
| 89 COMPILE_ASSERT(IsPod<const char*>::value, WTF_IsPod_const_char_pointer_true); | 89 static_assert(IsPod<const char*>::value, "WTF_IsPod_const_char_pointer_true"); |
| 90 COMPILE_ASSERT(IsPod<volatile char*>::value, WTF_IsPod_volatile_char_pointer_tru
e); | 90 static_assert(IsPod<volatile char*>::value, "WTF_IsPod_volatile_char_pointer_tru
e"); |
| 91 COMPILE_ASSERT(IsPod<double>::value, WTF_IsPod_double_true); | 91 static_assert(IsPod<double>::value, "WTF_IsPod_double_true"); |
| 92 COMPILE_ASSERT(IsPod<long double>::value, WTF_IsPod_long_double_true); | 92 static_assert(IsPod<long double>::value, "WTF_IsPod_long_double_true"); |
| 93 COMPILE_ASSERT(IsPod<float>::value, WTF_IsPod_float_true); | 93 static_assert(IsPod<float>::value, "WTF_IsPod_float_true"); |
| 94 struct VirtualClass { | 94 struct VirtualClass { |
| 95 virtual void A() { } | 95 virtual void A() { } |
| 96 }; | 96 }; |
| 97 COMPILE_ASSERT(!IsTriviallyMoveAssignable<VirtualClass>::value, WTF_IsTriviallyM
oveAssignable_VirtualClass_false); | 97 static_assert(!IsTriviallyMoveAssignable<VirtualClass>::value, "WTF_IsTriviallyM
oveAssignable_VirtualClass_false"); |
| 98 COMPILE_ASSERT(!IsScalar<VirtualClass>::value, WTF_IsScalar_class_false); | 98 static_assert(!IsScalar<VirtualClass>::value, "WTF_IsScalar_class_false"); |
| 99 COMPILE_ASSERT(IsScalar<VirtualClass*>::value, WTF_IsScalar_class_ptr_true); | 99 static_assert(IsScalar<VirtualClass*>::value, "WTF_IsScalar_class_ptr_true"); |
| 100 | 100 |
| 101 struct DestructorClass { | 101 struct DestructorClass { |
| 102 ~DestructorClass() { } | 102 ~DestructorClass() { } |
| 103 }; | 103 }; |
| 104 COMPILE_ASSERT(IsTriviallyMoveAssignable<DestructorClass>::value, WTF_IsTriviall
yMoveAssignable_DestructorClass_true); | 104 static_assert(IsTriviallyMoveAssignable<DestructorClass>::value, "WTF_IsTriviall
yMoveAssignable_DestructorClass_true"); |
| 105 COMPILE_ASSERT(IsTriviallyCopyAssignable<DestructorClass>::value, WTF_IsTriviall
yCopyAssignable_DestructorClass_true); | 105 static_assert(IsTriviallyCopyAssignable<DestructorClass>::value, "WTF_IsTriviall
yCopyAssignable_DestructorClass_true"); |
| 106 COMPILE_ASSERT(IsTriviallyDefaultConstructible<DestructorClass>::value, WTF_IsTr
iviallyDefaultConstructable_DestructorClass_true); | 106 static_assert(IsTriviallyDefaultConstructible<DestructorClass>::value, "WTF_IsTr
iviallyDefaultConstructable_DestructorClass_true"); |
| 107 | 107 |
| 108 struct MixedPrivate { | 108 struct MixedPrivate { |
| 109 int M2() { return m2; } | 109 int M2() { return m2; } |
| 110 int m1; | 110 int m1; |
| 111 private: | 111 private: |
| 112 int m2; | 112 int m2; |
| 113 }; | 113 }; |
| 114 COMPILE_ASSERT(IsTriviallyMoveAssignable<MixedPrivate>::value, WTF_IsTriviallyMo
veAssignable_MixedPrivate_true); | 114 static_assert(IsTriviallyMoveAssignable<MixedPrivate>::value, "WTF_IsTriviallyMo
veAssignable_MixedPrivate_true"); |
| 115 COMPILE_ASSERT(IsTriviallyCopyAssignable<MixedPrivate>::value, WTF_IsTriviallyCo
pyAssignable_MixedPrivate_true); | 115 static_assert(IsTriviallyCopyAssignable<MixedPrivate>::value, "WTF_IsTriviallyCo
pyAssignable_MixedPrivate_true"); |
| 116 COMPILE_ASSERT(IsTriviallyDefaultConstructible<MixedPrivate>::value, WTF_IsTrivi
allyDefaultConstructable_MixedPrivate_true); | 116 static_assert(IsTriviallyDefaultConstructible<MixedPrivate>::value, "WTF_IsTrivi
allyDefaultConstructable_MixedPrivate_true"); |
| 117 struct JustPrivate { | 117 struct JustPrivate { |
| 118 int M2() { return m2; } | 118 int M2() { return m2; } |
| 119 private: | 119 private: |
| 120 int m2; | 120 int m2; |
| 121 }; | 121 }; |
| 122 COMPILE_ASSERT(IsTriviallyMoveAssignable<JustPrivate>::value, WTF_IsTriviallyMov
eAssignable_JustPrivate_true); | 122 static_assert(IsTriviallyMoveAssignable<JustPrivate>::value, "WTF_IsTriviallyMov
eAssignable_JustPrivate_true"); |
| 123 COMPILE_ASSERT(IsTriviallyCopyAssignable<JustPrivate>::value, WTF_IsTriviallyCop
yAssignable_JustPrivate_true); | 123 static_assert(IsTriviallyCopyAssignable<JustPrivate>::value, "WTF_IsTriviallyCop
yAssignable_JustPrivate_true"); |
| 124 COMPILE_ASSERT(IsTriviallyDefaultConstructible<JustPrivate>::value, WTF_IsTrivia
llyDefaultConstructable_JustPrivate_true); | 124 static_assert(IsTriviallyDefaultConstructible<JustPrivate>::value, "WTF_IsTrivia
llyDefaultConstructable_JustPrivate_true"); |
| 125 struct JustPublic { | 125 struct JustPublic { |
| 126 int m2; | 126 int m2; |
| 127 }; | 127 }; |
| 128 COMPILE_ASSERT(IsTriviallyMoveAssignable<JustPublic>::value, WTF_IsTriviallyMove
Assignable_JustPublic_true); | 128 static_assert(IsTriviallyMoveAssignable<JustPublic>::value, "WTF_IsTriviallyMove
Assignable_JustPublic_true"); |
| 129 COMPILE_ASSERT(IsTriviallyCopyAssignable<JustPublic>::value, WTF_IsTriviallyCopy
Assignable_JustPublic_true); | 129 static_assert(IsTriviallyCopyAssignable<JustPublic>::value, "WTF_IsTriviallyCopy
Assignable_JustPublic_true"); |
| 130 COMPILE_ASSERT(IsTriviallyDefaultConstructible<JustPublic>::value, WTF_IsTrivial
lyDefaultConstructable_JustPublic_true); | 130 static_assert(IsTriviallyDefaultConstructible<JustPublic>::value, "WTF_IsTrivial
lyDefaultConstructable_JustPublic_true"); |
| 131 struct NestedInherited : public JustPublic, JustPrivate { | 131 struct NestedInherited : public JustPublic, JustPrivate { |
| 132 float m3; | 132 float m3; |
| 133 }; | 133 }; |
| 134 COMPILE_ASSERT(IsTriviallyMoveAssignable<NestedInherited>::value, WTF_IsTriviall
yMoveAssignable_NestedInherited_true); | 134 static_assert(IsTriviallyMoveAssignable<NestedInherited>::value, "WTF_IsTriviall
yMoveAssignable_NestedInherited_true"); |
| 135 COMPILE_ASSERT(IsTriviallyCopyAssignable<NestedInherited>::value, WTF_IsTriviall
yCopyAssignable_NestedInherited_true); | 135 static_assert(IsTriviallyCopyAssignable<NestedInherited>::value, "WTF_IsTriviall
yCopyAssignable_NestedInherited_true"); |
| 136 COMPILE_ASSERT(IsTriviallyDefaultConstructible<NestedInherited>::value, WTF_IsTr
iviallyDefaultConstructable_NestedInherited_true); | 136 static_assert(IsTriviallyDefaultConstructible<NestedInherited>::value, "WTF_IsTr
iviallyDefaultConstructable_NestedInherited_true"); |
| 137 struct NestedOwned { | 137 struct NestedOwned { |
| 138 JustPublic m1; | 138 JustPublic m1; |
| 139 JustPrivate m2; | 139 JustPrivate m2; |
| 140 float m3; | 140 float m3; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 COMPILE_ASSERT(IsTriviallyMoveAssignable<NestedOwned>::value, WTF_IsTriviallyMov
eAssignable_NestedOwned_true); | 143 static_assert(IsTriviallyMoveAssignable<NestedOwned>::value, "WTF_IsTriviallyMov
eAssignable_NestedOwned_true"); |
| 144 COMPILE_ASSERT(IsTriviallyCopyAssignable<NestedOwned>::value, WTF_IsTriviallyCop
yAssignable_NestedOwned_true); | 144 static_assert(IsTriviallyCopyAssignable<NestedOwned>::value, "WTF_IsTriviallyCop
yAssignable_NestedOwned_true"); |
| 145 COMPILE_ASSERT(IsTriviallyDefaultConstructible<NestedOwned>::value, WTF_IsTrivia
llyDefaultConstructable_NestedOwned_true); | 145 static_assert(IsTriviallyDefaultConstructible<NestedOwned>::value, "WTF_IsTrivia
llyDefaultConstructable_NestedOwned_true"); |
| 146 | 146 |
| 147 class NonCopyableClass { | 147 class NonCopyableClass { |
| 148 WTF_MAKE_NONCOPYABLE(NonCopyableClass); | 148 WTF_MAKE_NONCOPYABLE(NonCopyableClass); |
| 149 }; | 149 }; |
| 150 #if 0 // Compilers don't get this "right" yet if using = delete. | 150 #if 0 // Compilers don't get this "right" yet if using = delete. |
| 151 COMPILE_ASSERT(!IsTriviallyMoveAssignable<NonCopyableClass>::value, WTF_IsTrivia
llyMoveAssignable_NonCopyableClass_false); | 151 static_assert(!IsTriviallyMoveAssignable<NonCopyableClass>::value, "WTF_IsTrivia
llyMoveAssignable_NonCopyableClass_false"); |
| 152 COMPILE_ASSERT(!IsTriviallyCopyAssignable<NonCopyableClass>::value, WTF_IsTrivia
llyCopyAssignable_NonCopyableClass_false); | 152 static_assert(!IsTriviallyCopyAssignable<NonCopyableClass>::value, "WTF_IsTrivia
llyCopyAssignable_NonCopyableClass_false"); |
| 153 COMPILE_ASSERT(IsTriviallyDefaultConstructible<NonCopyableClass>::value, WTF_IsT
riviallyDefaultConstructable_NonCopyableClass_true); | 153 static_assert(IsTriviallyDefaultConstructible<NonCopyableClass>::value, "WTF_IsT
riviallyDefaultConstructable_NonCopyableClass_true"); |
| 154 #endif // 0 | 154 #endif // 0 |
| 155 | 155 |
| 156 enum IsConvertibleToIntegerCheck { }; | 156 enum IsConvertibleToIntegerCheck { }; |
| 157 COMPILE_ASSERT(IsConvertibleToInteger<IsConvertibleToIntegerCheck>::value, WTF_I
sConvertibleToInteger_enum_true); | 157 static_assert(IsConvertibleToInteger<IsConvertibleToIntegerCheck>::value, "WTF_I
sConvertibleToInteger_enum_true"); |
| 158 COMPILE_ASSERT(IsConvertibleToInteger<bool>::value, WTF_IsConvertibleToInteger_b
ool_true); | 158 static_assert(IsConvertibleToInteger<bool>::value, "WTF_IsConvertibleToInteger_b
ool_true"); |
| 159 COMPILE_ASSERT(IsConvertibleToInteger<char>::value, WTF_IsConvertibleToInteger_c
har_true); | 159 static_assert(IsConvertibleToInteger<char>::value, "WTF_IsConvertibleToInteger_c
har_true"); |
| 160 COMPILE_ASSERT(IsConvertibleToInteger<signed char>::value, WTF_IsConvertibleToIn
teger_signed_char_true); | 160 static_assert(IsConvertibleToInteger<signed char>::value, "WTF_IsConvertibleToIn
teger_signed_char_true"); |
| 161 COMPILE_ASSERT(IsConvertibleToInteger<unsigned char>::value, WTF_IsConvertibleTo
Integer_unsigned_char_true); | 161 static_assert(IsConvertibleToInteger<unsigned char>::value, "WTF_IsConvertibleTo
Integer_unsigned_char_true"); |
| 162 COMPILE_ASSERT(IsConvertibleToInteger<short>::value, WTF_IsConvertibleToInteger_
short_true); | 162 static_assert(IsConvertibleToInteger<short>::value, "WTF_IsConvertibleToInteger_
short_true"); |
| 163 COMPILE_ASSERT(IsConvertibleToInteger<unsigned short>::value, WTF_IsConvertibleT
oInteger_unsigned_short_true); | 163 static_assert(IsConvertibleToInteger<unsigned short>::value, "WTF_IsConvertibleT
oInteger_unsigned_short_true"); |
| 164 COMPILE_ASSERT(IsConvertibleToInteger<int>::value, WTF_IsConvertibleToInteger_in
t_true); | 164 static_assert(IsConvertibleToInteger<int>::value, "WTF_IsConvertibleToInteger_in
t_true"); |
| 165 COMPILE_ASSERT(IsConvertibleToInteger<unsigned>::value, WTF_IsConvertibleToInteg
er_unsigned_int_true); | 165 static_assert(IsConvertibleToInteger<unsigned>::value, "WTF_IsConvertibleToInteg
er_unsigned_int_true"); |
| 166 COMPILE_ASSERT(IsConvertibleToInteger<long>::value, WTF_IsConvertibleToInteger_l
ong_true); | 166 static_assert(IsConvertibleToInteger<long>::value, "WTF_IsConvertibleToInteger_l
ong_true"); |
| 167 COMPILE_ASSERT(IsConvertibleToInteger<unsigned long>::value, WTF_IsConvertibleTo
Integer_unsigned_long_true); | 167 static_assert(IsConvertibleToInteger<unsigned long>::value, "WTF_IsConvertibleTo
Integer_unsigned_long_true"); |
| 168 COMPILE_ASSERT(IsConvertibleToInteger<long long>::value, WTF_IsConvertibleToInte
ger_long_long_true); | 168 static_assert(IsConvertibleToInteger<long long>::value, "WTF_IsConvertibleToInte
ger_long_long_true"); |
| 169 COMPILE_ASSERT(IsConvertibleToInteger<unsigned long long>::value, WTF_IsConverti
bleToInteger_unsigned_long_long_true); | 169 static_assert(IsConvertibleToInteger<unsigned long long>::value, "WTF_IsConverti
bleToInteger_unsigned_long_long_true"); |
| 170 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) | 170 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) |
| 171 COMPILE_ASSERT(IsConvertibleToInteger<wchar_t>::value, WTF_IsConvertibleToIntege
r_wchar_t_true); | 171 static_assert(IsConvertibleToInteger<wchar_t>::value, "WTF_IsConvertibleToIntege
r_wchar_t_true"); |
| 172 #endif | 172 #endif |
| 173 COMPILE_ASSERT(IsConvertibleToInteger<double>::value, WTF_IsConvertibleToInteger
_double_true); | 173 static_assert(IsConvertibleToInteger<double>::value, "WTF_IsConvertibleToInteger
_double_true"); |
| 174 COMPILE_ASSERT(IsConvertibleToInteger<long double>::value, WTF_IsConvertibleToIn
teger_long_double_true); | 174 static_assert(IsConvertibleToInteger<long double>::value, "WTF_IsConvertibleToIn
teger_long_double_true"); |
| 175 COMPILE_ASSERT(IsConvertibleToInteger<float>::value, WTF_IsConvertibleToInteger_
float_true); | 175 static_assert(IsConvertibleToInteger<float>::value, "WTF_IsConvertibleToInteger_
float_true"); |
| 176 COMPILE_ASSERT(!IsConvertibleToInteger<char*>::value, WTF_IsConvertibleToInteger
_char_pointer_false); | 176 static_assert(!IsConvertibleToInteger<char*>::value, "WTF_IsConvertibleToInteger
_char_pointer_false"); |
| 177 COMPILE_ASSERT(!IsConvertibleToInteger<const char*>::value, WTF_IsConvertibleToI
nteger_const_char_pointer_false); | 177 static_assert(!IsConvertibleToInteger<const char*>::value, "WTF_IsConvertibleToI
nteger_const_char_pointer_false"); |
| 178 COMPILE_ASSERT(!IsConvertibleToInteger<volatile char*>::value, WTF_IsConvertible
ToInteger_volatile_char_pointer_false); | 178 static_assert(!IsConvertibleToInteger<volatile char*>::value, "WTF_IsConvertible
ToInteger_volatile_char_pointer_false"); |
| 179 COMPILE_ASSERT(!IsConvertibleToInteger<IsConvertibleToInteger<bool> >::value, WT
F_IsConvertibleToInteger_struct_false); | 179 static_assert(!IsConvertibleToInteger<IsConvertibleToInteger<bool> >::value, "WT
F_IsConvertibleToInteger_struct_false"); |
| 180 | 180 |
| 181 COMPILE_ASSERT((IsPointerConvertible<int, int>::Value), WTF_IsPointerConvertible
_same_type_true); | 181 static_assert((IsPointerConvertible<int, int>::Value), "WTF_IsPointerConvertible
_same_type_true"); |
| 182 COMPILE_ASSERT((!IsPointerConvertible<int, unsigned>::Value), WTF_IsPointerConve
rtible_int_to_unsigned_false); | 182 static_assert((!IsPointerConvertible<int, unsigned>::Value), "WTF_IsPointerConve
rtible_int_to_unsigned_false"); |
| 183 COMPILE_ASSERT((IsPointerConvertible<int, const int>::Value), WTF_IsPointerConve
rtible_int_to_const_int_true); | 183 static_assert((IsPointerConvertible<int, const int>::Value), "WTF_IsPointerConve
rtible_int_to_const_int_true"); |
| 184 COMPILE_ASSERT((!IsPointerConvertible<const int, int>::Value), WTF_IsPointerConv
ertible_const_int_to_int_false); | 184 static_assert((!IsPointerConvertible<const int, int>::Value), "WTF_IsPointerConv
ertible_const_int_to_int_false"); |
| 185 COMPILE_ASSERT((IsPointerConvertible<int, volatile int>::Value), WTF_IsPointerCo
nvertible_int_to_volatile_int_true); | 185 static_assert((IsPointerConvertible<int, volatile int>::Value), "WTF_IsPointerCo
nvertible_int_to_volatile_int_true"); |
| 186 | 186 |
| 187 COMPILE_ASSERT((IsSameType<bool, bool>::value), WTF_IsSameType_bool_true); | 187 static_assert((IsSameType<bool, bool>::value), "WTF_IsSameType_bool_true"); |
| 188 COMPILE_ASSERT((IsSameType<int*, int*>::value), WTF_IsSameType_int_pointer_true)
; | 188 static_assert((IsSameType<int*, int*>::value), "WTF_IsSameType_int_pointer_true"
); |
| 189 COMPILE_ASSERT((!IsSameType<int, int*>::value), WTF_IsSameType_int_int_pointer_f
alse); | 189 static_assert((!IsSameType<int, int*>::value), "WTF_IsSameType_int_int_pointer_f
alse"); |
| 190 COMPILE_ASSERT((!IsSameType<bool, const bool>::value), WTF_IsSameType_const_chan
ge_false); | 190 static_assert((!IsSameType<bool, const bool>::value), "WTF_IsSameType_const_chan
ge_false"); |
| 191 COMPILE_ASSERT((!IsSameType<bool, volatile bool>::value), WTF_IsSameType_volatil
e_change_false); | 191 static_assert((!IsSameType<bool, volatile bool>::value), "WTF_IsSameType_volatil
e_change_false"); |
| 192 | 192 |
| 193 template <typename T> | 193 template <typename T> |
| 194 class TestBaseClass { | 194 class TestBaseClass { |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 class TestDerivedClass : public TestBaseClass<int> { | 197 class TestDerivedClass : public TestBaseClass<int> { |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 COMPILE_ASSERT((IsSubclass<TestDerivedClass, TestBaseClass<int> >::value), WTF_T
est_IsSubclass_Derived_From_Base); | 200 static_assert((IsSubclass<TestDerivedClass, TestBaseClass<int> >::value), "WTF_T
est_IsSubclass_Derived_From_Base"); |
| 201 COMPILE_ASSERT((!IsSubclass<TestBaseClass<int>, TestDerivedClass>::value), WTF_T
est_IsSubclass_Base_From_Derived); | 201 static_assert((!IsSubclass<TestBaseClass<int>, TestDerivedClass>::value), "WTF_T
est_IsSubclass_Base_From_Derived"); |
| 202 COMPILE_ASSERT((IsSubclassOfTemplate<TestDerivedClass, TestBaseClass>::value), W
TF_Test_IsSubclassOfTemplate_Base_From_Derived); | 202 static_assert((IsSubclassOfTemplate<TestDerivedClass, TestBaseClass>::value), "W
TF_Test_IsSubclassOfTemplate_Base_From_Derived"); |
| 203 COMPILE_ASSERT((IsSameType<RemoveTemplate<TestBaseClass<int>, TestBaseClass>::Ty
pe, int>::value), WTF_Test_RemoveTemplate); | 203 static_assert((IsSameType<RemoveTemplate<TestBaseClass<int>, TestBaseClass>::Typ
e, int>::value), "WTF_Test_RemoveTemplate"); |
| 204 COMPILE_ASSERT((IsSameType<RemoveTemplate<int, TestBaseClass>::Type, int>::value
), WTF_Test_RemoveTemplate_WithoutTemplate); | 204 static_assert((IsSameType<RemoveTemplate<int, TestBaseClass>::Type, int>::value)
, "WTF_Test_RemoveTemplate_WithoutTemplate"); |
| 205 COMPILE_ASSERT((IsPointerConvertible<TestDerivedClass, TestBaseClass<int> >::Val
ue), WTF_Test_IsPointerConvertible_Derived_To_Base); | 205 static_assert((IsPointerConvertible<TestDerivedClass, TestBaseClass<int> >::Valu
e), "WTF_Test_IsPointerConvertible_Derived_To_Base"); |
| 206 COMPILE_ASSERT((!IsPointerConvertible<TestBaseClass<int>, TestDerivedClass>::Val
ue), WTF_Test_IsPointerConvertible_Base_To_Derived); | 206 static_assert((!IsPointerConvertible<TestBaseClass<int>, TestDerivedClass>::Valu
e), "WTF_Test_IsPointerConvertible_Base_To_Derived"); |
| 207 | 207 |
| 208 COMPILE_ASSERT((IsSameType<bool, RemoveConst<const bool>::Type>::value), WTF_tes
t_RemoveConst_const_bool); | 208 static_assert((IsSameType<bool, RemoveConst<const bool>::Type>::value), "WTF_tes
t_RemoveConst_const_bool"); |
| 209 COMPILE_ASSERT((!IsSameType<bool, RemoveConst<volatile bool>::Type>::value), WTF
_test_RemoveConst_volatile_bool); | 209 static_assert((!IsSameType<bool, RemoveConst<volatile bool>::Type>::value), "WTF
_test_RemoveConst_volatile_bool"); |
| 210 | 210 |
| 211 COMPILE_ASSERT((IsSameType<bool, RemoveVolatile<bool>::Type>::value), WTF_test_R
emoveVolatile_bool); | 211 static_assert((IsSameType<bool, RemoveVolatile<bool>::Type>::value), "WTF_test_R
emoveVolatile_bool"); |
| 212 COMPILE_ASSERT((!IsSameType<bool, RemoveVolatile<const bool>::Type>::value), WTF
_test_RemoveVolatile_const_bool); | 212 static_assert((!IsSameType<bool, RemoveVolatile<const bool>::Type>::value), "WTF
_test_RemoveVolatile_const_bool"); |
| 213 COMPILE_ASSERT((IsSameType<bool, RemoveVolatile<volatile bool>::Type>::value), W
TF_test_RemoveVolatile_volatile_bool); | 213 static_assert((IsSameType<bool, RemoveVolatile<volatile bool>::Type>::value), "W
TF_test_RemoveVolatile_volatile_bool"); |
| 214 | 214 |
| 215 COMPILE_ASSERT((IsSameType<bool, RemoveConstVolatile<bool>::Type>::value), WTF_t
est_RemoveConstVolatile_bool); | 215 static_assert((IsSameType<bool, RemoveConstVolatile<bool>::Type>::value), "WTF_t
est_RemoveConstVolatile_bool"); |
| 216 COMPILE_ASSERT((IsSameType<bool, RemoveConstVolatile<const bool>::Type>::value),
WTF_test_RemoveConstVolatile_const_bool); | 216 static_assert((IsSameType<bool, RemoveConstVolatile<const bool>::Type>::value),
"WTF_test_RemoveConstVolatile_const_bool"); |
| 217 COMPILE_ASSERT((IsSameType<bool, RemoveConstVolatile<volatile bool>::Type>::valu
e), WTF_test_RemoveConstVolatile_volatile_bool); | 217 static_assert((IsSameType<bool, RemoveConstVolatile<volatile bool>::Type>::value
), "WTF_test_RemoveConstVolatile_volatile_bool"); |
| 218 COMPILE_ASSERT((IsSameType<bool, RemoveConstVolatile<const volatile bool>::Type>
::value), WTF_test_RemoveConstVolatile_const_volatile_bool); | 218 static_assert((IsSameType<bool, RemoveConstVolatile<const volatile bool>::Type>:
:value), "WTF_test_RemoveConstVolatile_const_volatile_bool"); |
| 219 | 219 |
| 220 COMPILE_ASSERT((IsSameType<int, RemovePointer<int>::Type>::value), WTF_Test_Remo
vePointer_int); | 220 static_assert((IsSameType<int, RemovePointer<int>::Type>::value), "WTF_Test_Remo
vePointer_int"); |
| 221 COMPILE_ASSERT((IsSameType<int, RemovePointer<int*>::Type>::value), WTF_Test_Rem
ovePointer_int_pointer); | 221 static_assert((IsSameType<int, RemovePointer<int*>::Type>::value), "WTF_Test_Rem
ovePointer_int_pointer"); |
| 222 COMPILE_ASSERT((!IsSameType<int, RemovePointer<int**>::Type>::value), WTF_Test_R
emovePointer_int_pointer_pointer); | 222 static_assert((!IsSameType<int, RemovePointer<int**>::Type>::value), "WTF_Test_R
emovePointer_int_pointer_pointer"); |
| 223 | 223 |
| 224 COMPILE_ASSERT((IsSameType<int, RemoveReference<int>::Type>::value), WTF_Test_Re
moveReference_int); | 224 static_assert((IsSameType<int, RemoveReference<int>::Type>::value), "WTF_Test_Re
moveReference_int"); |
| 225 COMPILE_ASSERT((IsSameType<int, RemoveReference<int&>::Type>::value), WTF_Test_R
emoveReference_int_reference); | 225 static_assert((IsSameType<int, RemoveReference<int&>::Type>::value), "WTF_Test_R
emoveReference_int_reference"); |
| 226 | 226 |
| 227 | 227 |
| 228 typedef int IntArray[]; | 228 typedef int IntArray[]; |
| 229 typedef int IntArraySized[4]; | 229 typedef int IntArraySized[4]; |
| 230 | 230 |
| 231 COMPILE_ASSERT((IsArray<IntArray>::value), WTF_Test_IsArray_int_array); | 231 static_assert((IsArray<IntArray>::value), "WTF_Test_IsArray_int_array"); |
| 232 COMPILE_ASSERT((IsArray<IntArraySized>::value), WTF_Test_IsArray_int_sized_array
); | 232 static_assert((IsArray<IntArraySized>::value), "WTF_Test_IsArray_int_sized_array
"); |
| 233 | 233 |
| 234 COMPILE_ASSERT((IsSameType<int, RemoveExtent<IntArray>::Type>::value), WTF_Test_
RemoveExtent_int_array); | 234 static_assert((IsSameType<int, RemoveExtent<IntArray>::Type>::value), "WTF_Test_
RemoveExtent_int_array"); |
| 235 COMPILE_ASSERT((IsSameType<int, RemoveExtent<IntArraySized>::Type>::value), WTF_
Test_RemoveReference_int_sized_array); | 235 static_assert((IsSameType<int, RemoveExtent<IntArraySized>::Type>::value), "WTF_
Test_RemoveReference_int_sized_array"); |
| 236 | 236 |
| 237 } // namespace WTF | 237 } // namespace WTF |
| OLD | NEW |