X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..1df5f87f1309a8daa30dabdee855f48ae40d14ab:/wtf/HashTraits.h?ds=sidebyside diff --git a/wtf/HashTraits.h b/wtf/HashTraits.h index b3c0b7a..fba5afe 100644 --- a/wtf/HashTraits.h +++ b/wtf/HashTraits.h @@ -21,8 +21,8 @@ #ifndef WTF_HashTraits_h #define WTF_HashTraits_h -#include "Assertions.h" #include "HashFunctions.h" +#include "TypeTraits.h" #include #include @@ -31,47 +31,6 @@ namespace WTF { using std::pair; using std::make_pair; - template struct IsInteger { static const bool value = false; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - template<> struct IsInteger { static const bool value = true; }; - -#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) - template<> struct IsInteger { static const bool value = true; }; -#endif - - 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); - template struct HashTraits; template struct GenericHashTraitsBase; @@ -122,12 +81,14 @@ namespace WTF { static bool isDeletedValue(P* value) { return value == reinterpret_cast(-1); } }; - template struct HashTraits > : GenericHashTraits > { + template struct SimpleClassHashTraits : GenericHashTraits { static const bool emptyValueIsZero = true; - static void constructDeletedValue(RefPtr

& slot) { new (&slot) RefPtr

(HashTableDeletedValue); } - static bool isDeletedValue(const RefPtr

& value) { return value.isHashTableDeletedValue(); } + static void constructDeletedValue(T& slot) { new (&slot) T(HashTableDeletedValue); } + static bool isDeletedValue(const T& value) { return value.isHashTableDeletedValue(); } }; + template struct HashTraits > : SimpleClassHashTraits > { }; + // special traits for pairs, helpful for their use in HashMap implementation template