/* * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2009, 2010 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include "config.h" #include "TypeTraits.h" #include "Assertions.h" namespace WTF { COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_bool_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_char_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_signed_char_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_char_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_short_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_short_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_int_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_int_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_long_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_long_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_long_long_true); COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_unsigned_long_long_true); #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) COMPILE_ASSERT(IsInteger::value, WTF_IsInteger_wchar_t_true); #endif COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_char_pointer_false); COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_const_char_pointer_false); COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_volatile_char_pointer_false); COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_double_false); COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_float_false); COMPILE_ASSERT(IsFloatingPoint::value, WTF_IsFloatingPoint_float_true); COMPILE_ASSERT(IsFloatingPoint::value, WTF_IsFloatingPoint_double_true); COMPILE_ASSERT(IsFloatingPoint::value, WTF_IsFloatingPoint_long_double_true); COMPILE_ASSERT(!IsFloatingPoint::value, WTF_IsFloatingPoint_int_false); COMPILE_ASSERT(IsPod::value, WTF_IsPod_bool_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_char_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_signed_char_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_unsigned_char_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_short_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_unsigned_short_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_int_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_unsigned_int_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_long_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_unsigned_long_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_long_long_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_unsigned_long_long_true); #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) COMPILE_ASSERT(IsPod::value, WTF_IsPod_wchar_t_true); #endif COMPILE_ASSERT(IsPod::value, WTF_IsPod_char_pointer_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_const_char_pointer_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_volatile_char_pointer_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_double_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_long_double_true); COMPILE_ASSERT(IsPod::value, WTF_IsPod_float_true); COMPILE_ASSERT(!IsPod >::value, WTF_IsPod_struct_false); enum IsConvertibleToIntegerCheck { }; COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_enum_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_bool_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_char_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_signed_char_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_unsigned_char_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_short_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_unsigned_short_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_int_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_unsigned_int_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_long_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_unsigned_long_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_long_long_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_unsigned_long_long_true); #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_wchar_t_true); #endif COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_double_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_long_double_true); COMPILE_ASSERT(IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_float_true); COMPILE_ASSERT(!IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_char_pointer_false); COMPILE_ASSERT(!IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_const_char_pointer_false); COMPILE_ASSERT(!IsConvertibleToInteger::value, WTF_IsConvertibleToInteger_volatile_char_pointer_false); COMPILE_ASSERT(!IsConvertibleToInteger >::value, WTF_IsConvertibleToInteger_struct_false); COMPILE_ASSERT((IsSameType::value), WTF_IsSameType_bool_true); COMPILE_ASSERT((IsSameType::value), WTF_IsSameType_int_pointer_true); COMPILE_ASSERT((!IsSameType::value), WTF_IsSameType_int_int_pointer_false); COMPILE_ASSERT((!IsSameType::value), WTF_IsSameType_const_change_false); COMPILE_ASSERT((!IsSameType::value), WTF_IsSameType_volatile_change_false); template class TestBaseClass { }; class TestDerivedClass : public TestBaseClass { }; COMPILE_ASSERT((IsSubclass >::value), WTF_Test_IsSubclass_Derived_From_Base); COMPILE_ASSERT((!IsSubclass, TestDerivedClass>::value), WTF_Test_IsSubclass_Base_From_Derived); COMPILE_ASSERT((IsSubclassOfTemplate::value), WTF_Test_IsSubclassOfTemplate_Base_From_Derived); COMPILE_ASSERT((IsSameType, TestBaseClass>::Type, int>::value), WTF_Test_RemoveTemplate); COMPILE_ASSERT((IsSameType::Type, int>::value), WTF_Test_RemoveTemplate_WithoutTemplate); COMPILE_ASSERT((IsSameType::Type>::value), WTF_test_RemoveConst_const_bool); COMPILE_ASSERT((!IsSameType::Type>::value), WTF_test_RemoveConst_volatile_bool); COMPILE_ASSERT((IsSameType::Type>::value), WTF_test_RemoveVolatile_bool); COMPILE_ASSERT((!IsSameType::Type>::value), WTF_test_RemoveVolatile_const_bool); COMPILE_ASSERT((IsSameType::Type>::value), WTF_test_RemoveVolatile_volatile_bool); COMPILE_ASSERT((IsSameType::Type>::value), WTF_test_RemoveConstVolatile_bool); COMPILE_ASSERT((IsSameType::Type>::value), WTF_test_RemoveConstVolatile_const_bool); COMPILE_ASSERT((IsSameType::Type>::value), WTF_test_RemoveConstVolatile_volatile_bool); COMPILE_ASSERT((IsSameType::Type>::value), WTF_test_RemoveConstVolatile_const_volatile_bool); COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemovePointer_int); COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemovePointer_int_pointer); COMPILE_ASSERT((!IsSameType::Type>::value), WTF_Test_RemovePointer_int_pointer_pointer); COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemoveReference_int); COMPILE_ASSERT((IsSameType::Type>::value), WTF_Test_RemoveReference_int_reference); } // namespace WTF