| 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, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #ifndef TypeTraits_h | 22 #ifndef TypeTraits_h |
| 23 #define TypeTraits_h | 23 #define TypeTraits_h |
| 24 | 24 |
| 25 #include <utility> | 25 #include <utility> |
| 26 | 26 |
| 27 namespace WTF { | 27 namespace WTF { |
| 28 | 28 |
| 29 // The following are provided in this file: | 29 // The following are provided in this file: |
| 30 // | 30 // |
| 31 // IsInteger<T>::value | 31 // IsInteger<T>::value |
| 32 // IsPod<T>::value | 32 // IsPod<T>::value, see the definition for a note about its limitations |
| 33 // IsConvertibleToInteger<T>::value | 33 // IsConvertibleToInteger<T>::value |
| 34 // | 34 // |
| 35 // IsArray<T>::value | 35 // IsArray<T>::value |
| 36 // | 36 // |
| 37 // IsSameType<T, U>::value | 37 // IsSameType<T, U>::value |
| 38 // | 38 // |
| 39 // RemovePointer<T>::Type | 39 // RemovePointer<T>::Type |
| 40 // RemoveReference<T>::Type | 40 // RemoveReference<T>::Type |
| 41 // RemoveConst<T>::Type | 41 // RemoveConst<T>::Type |
| 42 // RemoveVolatile<T>::Type | 42 // RemoveVolatile<T>::Type |
| (...skipping 22 matching lines...) Expand all Loading... |
| 65 template<> struct IsInteger<wchar_t> { static const bool value =
true; }; | 65 template<> struct IsInteger<wchar_t> { static const bool value =
true; }; |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 template<typename T> struct IsFloatingPoint { static const bool value =
false; }; | 68 template<typename T> struct IsFloatingPoint { static const bool value =
false; }; |
| 69 template<> struct IsFloatingPoint<float> { static const bool value =
true; }; | 69 template<> struct IsFloatingPoint<float> { static const bool value =
true; }; |
| 70 template<> struct IsFloatingPoint<double> { static const bool value =
true; }; | 70 template<> struct IsFloatingPoint<double> { static const bool value =
true; }; |
| 71 template<> struct IsFloatingPoint<long double> { static const bool value =
true; }; | 71 template<> struct IsFloatingPoint<long double> { static const bool value =
true; }; |
| 72 | 72 |
| 73 template<typename T> struct IsArithmetic { static const bool value =
IsInteger<T>::value || IsFloatingPoint<T>::value; }; | 73 template<typename T> struct IsArithmetic { static const bool value =
IsInteger<T>::value || IsFloatingPoint<T>::value; }; |
| 74 | 74 |
| 75 template<typename T> struct IsPointer { | |
| 76 static const bool value = false; | |
| 77 }; | |
| 78 | |
| 79 template<typename P> struct IsPointer<const P*> { | |
| 80 static const bool value = true; | |
| 81 }; | |
| 82 | |
| 83 template<typename P> struct IsPointer<P*> { | |
| 84 static const bool value = true; | |
| 85 }; | |
| 86 | |
| 87 template<typename T> struct IsEnum { | |
| 88 static const bool value = __is_enum(T); | |
| 89 }; | |
| 90 | |
| 91 template<typename T> struct IsScalar { | |
| 92 static const bool value = IsEnum<T>::value || IsArithmetic<T>::value ||
IsPointer<T>::value; | |
| 93 }; | |
| 94 | |
| 95 template<typename T> struct IsWeak { static const bool value =
false; }; | 75 template<typename T> struct IsWeak { static const bool value =
false; }; |
| 96 | 76 |
| 97 enum WeakHandlingFlag { | 77 enum WeakHandlingFlag { |
| 98 NoWeakHandlingInCollections, | 78 NoWeakHandlingInCollections, |
| 99 WeakHandlingInCollections | 79 WeakHandlingInCollections |
| 100 }; | 80 }; |
| 101 | 81 |
| 102 template <typename T> struct IsPod { | 82 // IsPod is misnamed as it doesn't cover all plain old data (pod) types. |
| 103 static const bool value = __is_pod(T); | 83 // Specifically, it doesn't allow for enums or for structs. |
| 104 }; | 84 template <typename T> struct IsPod { static const bool value =
IsArithmetic<T>::value; }; |
| 105 | 85 template <typename P> struct IsPod<P*> { static const bool value =
true; }; |
| 106 template <typename T> struct IsTriviallyCopyAssignable { | |
| 107 static const bool value = __has_trivial_assign(T); | |
| 108 }; | |
| 109 | |
| 110 template <typename T> struct IsTriviallyMoveAssignable { | |
| 111 static const bool value = __has_trivial_assign(T); | |
| 112 }; | |
| 113 | |
| 114 template <typename T> struct IsTriviallyDefaultConstructible { | |
| 115 static const bool value = __has_trivial_constructor(T); | |
| 116 }; | |
| 117 | |
| 118 template <typename T> struct IsTriviallyDestructible { | |
| 119 static const bool value = __has_trivial_destructor(T); | |
| 120 }; | |
| 121 | 86 |
| 122 template<typename T> class IsConvertibleToInteger { | 87 template<typename T> class IsConvertibleToInteger { |
| 123 // Avoid "possible loss of data" warning when using Microsoft's C++ comp
iler | 88 // Avoid "possible loss of data" warning when using Microsoft's C++ comp
iler |
| 124 // by not converting int's to doubles. | 89 // by not converting int's to doubles. |
| 125 template<bool performCheck, typename U> class IsConvertibleToDouble; | 90 template<bool performCheck, typename U> class IsConvertibleToDouble; |
| 126 template<typename U> class IsConvertibleToDouble<false, U> { | 91 template<typename U> class IsConvertibleToDouble<false, U> { |
| 127 public: | 92 public: |
| 128 static const bool value = false; | 93 static const bool value = false; |
| 129 }; | 94 }; |
| 130 | 95 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 }; | 337 }; |
| 373 | 338 |
| 374 template<typename T, typename U> | 339 template<typename T, typename U> |
| 375 struct NeedsTracing<std::pair<T, U> > { | 340 struct NeedsTracing<std::pair<T, U> > { |
| 376 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; | 341 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; |
| 377 }; | 342 }; |
| 378 | 343 |
| 379 } // namespace WTF | 344 } // namespace WTF |
| 380 | 345 |
| 381 #endif // TypeTraits_h | 346 #endif // TypeTraits_h |
| OLD | NEW |