| 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, see the definition for a note about its limitations | |
| 33 // IsConvertibleToInteger<T>::value | 32 // IsConvertibleToInteger<T>::value |
| 34 // | 33 // |
| 35 // IsArray<T>::value | 34 // IsArray<T>::value |
| 36 // | 35 // |
| 37 // IsSameType<T, U>::value | 36 // IsSameType<T, U>::value |
| 38 // | 37 // |
| 39 // RemovePointer<T>::Type | 38 // RemovePointer<T>::Type |
| 40 // RemoveReference<T>::Type | 39 // RemoveReference<T>::Type |
| 41 // RemoveConst<T>::Type | 40 // RemoveConst<T>::Type |
| 42 // RemoveVolatile<T>::Type | 41 // RemoveVolatile<T>::Type |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 | 71 |
| 73 template<typename T> struct IsArithmetic { static const bool value =
IsInteger<T>::value || IsFloatingPoint<T>::value; }; | 72 template<typename T> struct IsArithmetic { static const bool value =
IsInteger<T>::value || IsFloatingPoint<T>::value; }; |
| 74 | 73 |
| 75 template<typename T> struct IsWeak { static const bool value =
false; }; | 74 template<typename T> struct IsWeak { static const bool value =
false; }; |
| 76 | 75 |
| 77 enum WeakHandlingFlag { | 76 enum WeakHandlingFlag { |
| 78 NoWeakHandlingInCollections, | 77 NoWeakHandlingInCollections, |
| 79 WeakHandlingInCollections | 78 WeakHandlingInCollections |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 // IsPod is misnamed as it doesn't cover all plain old data (pod) types. | |
| 83 // Specifically, it doesn't allow for enums or for structs. | |
| 84 template <typename T> struct IsPod { static const bool value =
IsArithmetic<T>::value; }; | |
| 85 template <typename P> struct IsPod<P*> { static const bool value =
true; }; | |
| 86 | |
| 87 template<typename T> class IsConvertibleToInteger { | 81 template<typename T> class IsConvertibleToInteger { |
| 88 // Avoid "possible loss of data" warning when using Microsoft's C++ comp
iler | 82 // Avoid "possible loss of data" warning when using Microsoft's C++ comp
iler |
| 89 // by not converting int's to doubles. | 83 // by not converting int's to doubles. |
| 90 template<bool performCheck, typename U> class IsConvertibleToDouble; | 84 template<bool performCheck, typename U> class IsConvertibleToDouble; |
| 91 template<typename U> class IsConvertibleToDouble<false, U> { | 85 template<typename U> class IsConvertibleToDouble<false, U> { |
| 92 public: | 86 public: |
| 93 static const bool value = false; | 87 static const bool value = false; |
| 94 }; | 88 }; |
| 95 | 89 |
| 96 template<typename U> class IsConvertibleToDouble<true, U> { | 90 template<typename U> class IsConvertibleToDouble<true, U> { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 }; | 305 }; |
| 312 | 306 |
| 313 template<typename T, typename U> | 307 template<typename T, typename U> |
| 314 struct NeedsTracing<std::pair<T, U> > { | 308 struct NeedsTracing<std::pair<T, U> > { |
| 315 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; | 309 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value |
| IsWeak<T>::value || IsWeak<U>::value; |
| 316 }; | 310 }; |
| 317 | 311 |
| 318 } // namespace WTF | 312 } // namespace WTF |
| 319 | 313 |
| 320 #endif // TypeTraits_h | 314 #endif // TypeTraits_h |
| OLD | NEW |