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

Unified Diff: Source/wtf/TypeTraits.h

Issue 581683002: Expanding Type Traits to make Vector use mem ops more. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More efficient Vector with more type traits. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/wtf/TypeTraits.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/TypeTraits.h
diff --git a/Source/wtf/TypeTraits.h b/Source/wtf/TypeTraits.h
index 3637304b4680f221d39d09d3591ca9157513150e..908f06cf91733e16c98e16f9f751b478e1d138ec 100644
--- a/Source/wtf/TypeTraits.h
+++ b/Source/wtf/TypeTraits.h
@@ -29,7 +29,7 @@ namespace WTF {
// The following are provided in this file:
//
// IsInteger<T>::value
- // IsPod<T>::value, see the definition for a note about its limitations
+ // IsPod<T>::value
// IsConvertibleToInteger<T>::value
//
// IsArray<T>::value
@@ -72,6 +72,26 @@ namespace WTF {
template<typename T> struct IsArithmetic { static const bool value = IsInteger<T>::value || IsFloatingPoint<T>::value; };
+ template<typename T> struct IsPointer {
+ static const bool value = false;
+ };
+
+ template<typename P> struct IsPointer<const P*> {
+ static const bool value = true;
+ };
+
+ template<typename P> struct IsPointer<P*> {
+ static const bool value = true;
+ };
+
+ template<typename T> struct IsEnum {
+ static const bool value = __is_enum(T);
+ };
+
+ template<typename T> struct IsScalar {
+ static const bool value = IsEnum<T>::value || IsArithmetic<T>::value || IsPointer<T>::value;
+ };
+
template<typename T> struct IsWeak { static const bool value = false; };
enum WeakHandlingFlag {
@@ -79,10 +99,25 @@ namespace WTF {
WeakHandlingInCollections
};
- // IsPod is misnamed as it doesn't cover all plain old data (pod) types.
- // Specifically, it doesn't allow for enums or for structs.
- template <typename T> struct IsPod { static const bool value = IsArithmetic<T>::value; };
- template <typename P> struct IsPod<P*> { static const bool value = true; };
+ template <typename T> struct IsPod {
+ static const bool value = __is_pod(T);
+ };
+
+ template <typename T> struct IsTriviallyCopyAssignable {
+ static const bool value = __has_trivial_assign(T);
+ };
+
+ template <typename T> struct IsTriviallyMoveAssignable {
+ static const bool value = __has_trivial_assign(T);
+ };
+
+ template <typename T> struct IsTriviallyDefaultConstructible {
+ static const bool value = __has_trivial_constructor(T);
+ };
+
+ template <typename T> struct IsTriviallyDestructible {
+ static const bool value = __has_trivial_destructor(T);
+ };
template<typename T> class IsConvertibleToInteger {
// Avoid "possible loss of data" warning when using Microsoft's C++ compiler
« 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