Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: Source/wtf/TypeTraits.h

Issue 594023002: Expanding Type Traits to make Vector use mem ops more. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/wtf/TypeTraits.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 32 // IsPod<T>::value
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
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
75 template<typename T> struct IsWeak { static const bool value = false; }; 95 template<typename T> struct IsWeak { static const bool value = false; };
76 96
77 enum WeakHandlingFlag { 97 enum WeakHandlingFlag {
78 NoWeakHandlingInCollections, 98 NoWeakHandlingInCollections,
79 WeakHandlingInCollections 99 WeakHandlingInCollections
80 }; 100 };
81 101
82 // IsPod is misnamed as it doesn't cover all plain old data (pod) types. 102 template <typename T> struct IsPod {
83 // Specifically, it doesn't allow for enums or for structs. 103 static const bool value = __is_pod(T);
84 template <typename T> struct IsPod { static const bool value = IsArithmetic<T>::value; }; 104 };
85 template <typename P> struct IsPod<P*> { static const bool value = true; }; 105
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 };
86 121
87 template<typename T> class IsConvertibleToInteger { 122 template<typename T> class IsConvertibleToInteger {
88 // Avoid "possible loss of data" warning when using Microsoft's C++ comp iler 123 // Avoid "possible loss of data" warning when using Microsoft's C++ comp iler
89 // by not converting int's to doubles. 124 // by not converting int's to doubles.
90 template<bool performCheck, typename U> class IsConvertibleToDouble; 125 template<bool performCheck, typename U> class IsConvertibleToDouble;
91 template<typename U> class IsConvertibleToDouble<false, U> { 126 template<typename U> class IsConvertibleToDouble<false, U> {
92 public: 127 public:
93 static const bool value = false; 128 static const bool value = false;
94 }; 129 };
95 130
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 }; 372 };
338 373
339 template<typename T, typename U> 374 template<typename T, typename U>
340 struct NeedsTracing<std::pair<T, U> > { 375 struct NeedsTracing<std::pair<T, U> > {
341 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value; 376 static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value | | IsWeak<T>::value || IsWeak<U>::value;
342 }; 377 };
343 378
344 } // namespace WTF 379 } // namespace WTF
345 380
346 #endif // TypeTraits_h 381 #endif // TypeTraits_h
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/TypeTraits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698