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

Unified Diff: third_party/WebKit/Source/wtf/TypeTraits.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « third_party/WebKit/Source/wtf/TriState.h ('k') | third_party/WebKit/Source/wtf/TypeTraits.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/TypeTraits.h
diff --git a/third_party/WebKit/Source/wtf/TypeTraits.h b/third_party/WebKit/Source/wtf/TypeTraits.h
index b561606e52e7fafdfbe0fc1f29d3902aef1f1079..9d25c36e8b861b4735b71b33341b6f763cd8860f 100644
--- a/third_party/WebKit/Source/wtf/TypeTraits.h
+++ b/third_party/WebKit/Source/wtf/TypeTraits.h
@@ -1,4 +1,4 @@
- /*
+/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
@@ -27,7 +27,8 @@
namespace WTF {
-template<typename T> class RawPtr;
+template <typename T>
+class RawPtr;
// The following are provided in this file:
//
@@ -48,353 +49,429 @@ template<typename T> class RawPtr;
//
// static_assert's in TypeTraits.cpp illustrate their usage and what they do.
-template <bool Predicate, class T = void> struct EnableIf;
-template <class T> struct EnableIf<true, T> { typedef T Type; };
-
-template <typename T> struct IsInteger { static const bool value = false; };
-template <> struct IsInteger<bool> { static const bool value = true; };
-template <> struct IsInteger<char> { static const bool value = true; };
-template <> struct IsInteger<signed char> { static const bool value = true; };
-template <> struct IsInteger<unsigned char> { static const bool value = true; };
-template <> struct IsInteger<short> { static const bool value = true; };
-template <> struct IsInteger<unsigned short> { static const bool value = true; };
-template <> struct IsInteger<int> { static const bool value = true; };
-template <> struct IsInteger<unsigned> { static const bool value = true; };
-template <> struct IsInteger<long> { static const bool value = true; };
-template <> struct IsInteger<unsigned long> { static const bool value = true; };
-template <> struct IsInteger<long long> { static const bool value = true; };
-template <> struct IsInteger<unsigned long long> { static const bool value = true; };
+template <bool Predicate, class T = void>
+struct EnableIf;
+template <class T>
+struct EnableIf<true, T> { typedef T Type; };
+
+template <typename T>
+struct IsInteger { static const bool value = false; };
+template <>
+struct IsInteger<bool> { static const bool value = true; };
+template <>
+struct IsInteger<char> { static const bool value = true; };
+template <>
+struct IsInteger<signed char> { static const bool value = true; };
+template <>
+struct IsInteger<unsigned char> { static const bool value = true; };
+template <>
+struct IsInteger<short> { static const bool value = true; };
+template <>
+struct IsInteger<unsigned short> { static const bool value = true; };
+template <>
+struct IsInteger<int> { static const bool value = true; };
+template <>
+struct IsInteger<unsigned> { static const bool value = true; };
+template <>
+struct IsInteger<long> { static const bool value = true; };
+template <>
+struct IsInteger<unsigned long> { static const bool value = true; };
+template <>
+struct IsInteger<long long> { static const bool value = true; };
+template <>
+struct IsInteger<unsigned long long> { static const bool value = true; };
#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
-template <> struct IsInteger<wchar_t> { static const bool value = true; };
+template <>
+struct IsInteger<wchar_t> { static const bool value = true; };
#endif
-template <typename T> struct IsFloatingPoint { static const bool value = false; };
-template <> struct IsFloatingPoint<float> { static const bool value = true; };
-template <> struct IsFloatingPoint<double> { static const bool value = true; };
-template <> struct IsFloatingPoint<long double> { static const bool value = true; };
+template <typename T>
+struct IsFloatingPoint { static const bool value = false; };
+template <>
+struct IsFloatingPoint<float> { static const bool value = true; };
+template <>
+struct IsFloatingPoint<double> { static const bool value = true; };
+template <>
+struct IsFloatingPoint<long double> { static const bool value = true; };
-template <typename T> struct IsArithmetic { static const bool value = IsInteger<T>::value || IsFloatingPoint<T>::value; };
+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 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<const P*> {
+ static const bool value = true;
};
-template <typename P> struct IsPointer<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 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 IsScalar {
+ static const bool value = IsEnum<T>::value || IsArithmetic<T>::value || IsPointer<T>::value;
};
-template <typename T> struct IsWeak {
- static const bool value = false;
+template <typename T>
+struct IsWeak {
+ static const bool value = false;
};
enum WeakHandlingFlag {
- NoWeakHandlingInCollections,
- WeakHandlingInCollections
+ NoWeakHandlingInCollections,
+ WeakHandlingInCollections
};
-template <typename T> struct IsPod {
- static const bool value = __is_pod(T);
+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 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 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 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>
+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
- // by not converting int's to doubles.
- template <bool performCheck, typename U> class IsConvertibleToDouble;
- template <typename U> class IsConvertibleToDouble<false, U> {
- public:
- static const bool value = false;
- };
+template <typename T>
+class IsConvertibleToInteger {
+ // Avoid "possible loss of data" warning when using Microsoft's C++ compiler
+ // by not converting int's to doubles.
+ template <bool performCheck, typename U>
+ class IsConvertibleToDouble;
+ template <typename U>
+ class IsConvertibleToDouble<false, U> {
+ public:
+ static const bool value = false;
+ };
- template <typename U> class IsConvertibleToDouble<true, U> {
- typedef char YesType;
- struct NoType {
- char padding[8];
- };
-
- static YesType floatCheck(long double);
- static NoType floatCheck(...);
- static T& t;
- public:
- static const bool value = sizeof(floatCheck(t)) == sizeof(YesType);
+ template <typename U>
+ class IsConvertibleToDouble<true, U> {
+ typedef char YesType;
+ struct NoType {
+ char padding[8];
};
-public:
- static const bool value = IsInteger<T>::value || IsConvertibleToDouble<!IsInteger<T>::value, T>::value;
+ static YesType floatCheck(long double);
+ static NoType floatCheck(...);
+ static T& t;
+
+ public:
+ static const bool value = sizeof(floatCheck(t)) == sizeof(YesType);
+ };
+
+ public:
+ static const bool value = IsInteger<T>::value || IsConvertibleToDouble<!IsInteger<T>::value, T>::value;
};
-template <typename From, typename To> class IsPointerConvertible {
- typedef char YesType;
- struct NoType {
- char padding[8];
- };
+template <typename From, typename To>
+class IsPointerConvertible {
+ typedef char YesType;
+ struct NoType {
+ char padding[8];
+ };
- static YesType convertCheck(To* x);
- static NoType convertCheck(...);
-public:
- enum {
- Value = (sizeof(YesType) == sizeof(convertCheck(static_cast<From*>(0))))
- };
+ static YesType convertCheck(To* x);
+ static NoType convertCheck(...);
+
+ public:
+ enum {
+ Value = (sizeof(YesType) == sizeof(convertCheck(static_cast<From*>(0))))
+ };
};
-template <class T> struct IsArray {
- static const bool value = false;
+template <class T>
+struct IsArray {
+ static const bool value = false;
};
-template <class T> struct IsArray<T[]> {
- static const bool value = true;
+template <class T>
+struct IsArray<T[]> {
+ static const bool value = true;
};
-template <class T, size_t N> struct IsArray<T[N]> {
- static const bool value = true;
+template <class T, size_t N>
+struct IsArray<T[N]> {
+ static const bool value = true;
};
-template <typename T, typename U> struct IsSameType {
- static const bool value = false;
+template <typename T, typename U>
+struct IsSameType {
+ static const bool value = false;
};
-template <typename T> struct IsSameType<T, T> {
- static const bool value = true;
+template <typename T>
+struct IsSameType<T, T> {
+ static const bool value = true;
};
-template <typename T, typename U> class IsSubclass {
- typedef char YesType;
- struct NoType {
- char padding[8];
- };
+template <typename T, typename U>
+class IsSubclass {
+ typedef char YesType;
+ struct NoType {
+ char padding[8];
+ };
+
+ static YesType subclassCheck(U*);
+ static NoType subclassCheck(...);
+ static T* t;
- static YesType subclassCheck(U*);
- static NoType subclassCheck(...);
- static T* t;
-public:
- static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
+ public:
+ static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
};
-template <typename T, template <typename... V> class U> class IsSubclassOfTemplate {
- typedef char YesType;
- struct NoType {
- char padding[8];
- };
+template <typename T, template <typename... V> class U>
+class IsSubclassOfTemplate {
+ typedef char YesType;
+ struct NoType {
+ char padding[8];
+ };
- template <typename... W> static YesType subclassCheck(U<W...>*);
- static NoType subclassCheck(...);
- static T* t;
-public:
- static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
+ template <typename... W>
+ static YesType subclassCheck(U<W...>*);
+ static NoType subclassCheck(...);
+ static T* t;
+
+ public:
+ static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
};
template <typename T, template <typename V, size_t W> class U>
class IsSubclassOfTemplateTypenameSize {
- typedef char YesType;
- struct NoType {
- char padding[8];
- };
+ typedef char YesType;
+ struct NoType {
+ char padding[8];
+ };
+
+ template <typename X, size_t Y>
+ static YesType subclassCheck(U<X, Y>*);
+ static NoType subclassCheck(...);
+ static T* t;
- template <typename X, size_t Y> static YesType subclassCheck(U<X, Y>*);
- static NoType subclassCheck(...);
- static T* t;
-public:
- static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
+ public:
+ static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
};
template <typename T, template <typename V, size_t W, typename X> class U>
class IsSubclassOfTemplateTypenameSizeTypename {
- typedef char YesType;
- struct NoType {
- char padding[8];
- };
+ typedef char YesType;
+ struct NoType {
+ char padding[8];
+ };
+
+ template <typename Y, size_t Z, typename A>
+ static YesType subclassCheck(U<Y, Z, A>*);
+ static NoType subclassCheck(...);
+ static T* t;
- template <typename Y, size_t Z, typename A> static YesType subclassCheck(U<Y, Z, A>*);
- static NoType subclassCheck(...);
- static T* t;
-public:
- static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
+ public:
+ static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
};
template <typename T, template <class V> class OuterTemplate>
struct RemoveTemplate {
- typedef T Type;
+ typedef T Type;
};
template <typename T, template <class V> class OuterTemplate>
struct RemoveTemplate<OuterTemplate<T>, OuterTemplate> {
- typedef T Type;
+ typedef T Type;
};
-template <typename T> struct RemoveConst {
- typedef T Type;
+template <typename T>
+struct RemoveConst {
+ typedef T Type;
};
-template <typename T> struct RemoveConst<const T> {
- typedef T Type;
+template <typename T>
+struct RemoveConst<const T> {
+ typedef T Type;
};
-template <typename T> struct RemoveVolatile {
- typedef T Type;
+template <typename T>
+struct RemoveVolatile {
+ typedef T Type;
};
-template <typename T> struct RemoveVolatile<volatile T> {
- typedef T Type;
+template <typename T>
+struct RemoveVolatile<volatile T> {
+ typedef T Type;
};
-template <typename T> struct RemoveConstVolatile {
- typedef typename RemoveVolatile<typename RemoveConst<T>::Type>::Type Type;
+template <typename T>
+struct RemoveConstVolatile {
+ typedef typename RemoveVolatile<typename RemoveConst<T>::Type>::Type Type;
};
-template <typename T> struct RemovePointer {
- typedef T Type;
+template <typename T>
+struct RemovePointer {
+ typedef T Type;
};
-template <typename T> struct RemovePointer<T*> {
- typedef T Type;
+template <typename T>
+struct RemovePointer<T*> {
+ typedef T Type;
};
-template <typename T> struct RemoveReference {
- typedef T Type;
+template <typename T>
+struct RemoveReference {
+ typedef T Type;
};
-template <typename T> struct RemoveReference<T&> {
- typedef T Type;
+template <typename T>
+struct RemoveReference<T&> {
+ typedef T Type;
};
-template <typename T> struct RemoveReference<T&&> {
- typedef T Type;
+template <typename T>
+struct RemoveReference<T&&> {
+ typedef T Type;
};
-template <typename T> struct RemoveExtent {
- typedef T Type;
+template <typename T>
+struct RemoveExtent {
+ typedef T Type;
};
-template <typename T> struct RemoveExtent<T[]> {
- typedef T Type;
+template <typename T>
+struct RemoveExtent<T[]> {
+ typedef T Type;
};
-template <typename T, size_t N> struct RemoveExtent<T[N]> {
- typedef T Type;
+template <typename T, size_t N>
+struct RemoveExtent<T[N]> {
+ typedef T Type;
};
// Determines whether this type has a vtable.
-template <typename T> struct IsPolymorphic {
- static const bool value = __is_polymorphic(T);
+template <typename T>
+struct IsPolymorphic {
+ static const bool value = __is_polymorphic(T);
};
#define EnsurePtrConvertibleArgDecl(From, To) \
- typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Type = true
+ typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Type = true
#define EnsurePtrConvertibleArgDefn(From, To) \
- typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Type
+ typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Type
-} // namespace WTF
+} // namespace WTF
namespace blink {
class Visitor;
-} // namespace blink
+} // namespace blink
namespace WTF {
template <typename T>
class NeedsTracing {
- typedef char YesType;
- typedef struct NoType {
- char padding[8];
- } NoType;
+ typedef char YesType;
+ typedef struct NoType {
+ char padding[8];
+ } NoType;
- // Note that this also checks if a superclass of V has a trace method.
- template <typename V> static YesType checkHasTraceMethod(V* v, blink::Visitor* p = nullptr, typename EnableIf<IsSameType<decltype(v->trace(p)), void>::value>::Type* g = nullptr);
- template <typename V> static NoType checkHasTraceMethod(...);
-public:
- // We add sizeof(T) to both sides here, because we want it to fail for
- // incomplete types. Otherwise it just assumes that incomplete types do not
- // have a trace method, which may not be true.
- static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTraceMethod<T>(nullptr)) + sizeof(T);
+ // Note that this also checks if a superclass of V has a trace method.
+ template <typename V>
+ static YesType checkHasTraceMethod(V* v, blink::Visitor* p = nullptr, typename EnableIf<IsSameType<decltype(v->trace(p)), void>::value>::Type* g = nullptr);
+ template <typename V>
+ static NoType checkHasTraceMethod(...);
+
+ public:
+ // We add sizeof(T) to both sides here, because we want it to fail for
+ // incomplete types. Otherwise it just assumes that incomplete types do not
+ // have a trace method, which may not be true.
+ static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasTraceMethod<T>(nullptr)) + sizeof(T);
};
// Convenience template wrapping the NeedsTracingLazily template in
// Collection Traits. It helps make the code more readable.
template <typename Traits>
class NeedsTracingTrait {
-public:
- static const bool value = Traits::template NeedsTracingLazily<>::value;
+ public:
+ static const bool value = Traits::template NeedsTracingLazily<>::value;
};
template <typename T, typename U>
struct NeedsTracing<std::pair<T, U>> {
- static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value || IsWeak<T>::value || IsWeak<U>::value;
+ static const bool value = NeedsTracing<T>::value || NeedsTracing<U>::value || IsWeak<T>::value || IsWeak<U>::value;
};
// This is used to check that DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects are not
// stored in off-heap Vectors, HashTables etc.
template <typename T>
struct AllowsOnlyPlacementNew {
-private:
- using YesType = char;
- struct NoType {
- char padding[8];
- };
+ private:
+ using YesType = char;
+ struct NoType {
+ char padding[8];
+ };
+
+ template <typename U>
+ static YesType checkMarker(typename U::IsAllowOnlyPlacementNew*);
+ template <typename U>
+ static NoType checkMarker(...);
- template <typename U> static YesType checkMarker(typename U::IsAllowOnlyPlacementNew*);
- template <typename U> static NoType checkMarker(...);
-public:
- static const bool value = sizeof(checkMarker<T>(nullptr)) == sizeof(YesType);
+ public:
+ static const bool value = sizeof(checkMarker<T>(nullptr)) == sizeof(YesType);
};
-template<typename T>
+template <typename T>
class IsGarbageCollectedType {
- typedef char YesType;
- typedef struct NoType {
- char padding[8];
- } NoType;
+ typedef char YesType;
+ typedef struct NoType {
+ char padding[8];
+ } NoType;
+
+ template <typename U>
+ static YesType checkGarbageCollectedType(typename U::IsGarbageCollectedTypeMarker*);
+ template <typename U>
+ static NoType checkGarbageCollectedType(...);
- template <typename U> static YesType checkGarbageCollectedType(typename U::IsGarbageCollectedTypeMarker*);
- template <typename U> static NoType checkGarbageCollectedType(...);
-public:
- static const bool value = (sizeof(YesType) == sizeof(checkGarbageCollectedType<T>(nullptr)));
+ public:
+ static const bool value = (sizeof(YesType) == sizeof(checkGarbageCollectedType<T>(nullptr)));
};
-template<typename T>
+template <typename T>
class IsPointerToGarbageCollectedType {
-public:
- static const bool value = false;
+ public:
+ static const bool value = false;
};
-template<typename T>
+template <typename T>
class IsPointerToGarbageCollectedType<T*> {
-public:
- static const bool value = IsGarbageCollectedType<T>::value;
+ public:
+ static const bool value = IsGarbageCollectedType<T>::value;
};
-template<typename T>
+template <typename T>
class IsPointerToGarbageCollectedType<RawPtr<T>> {
-public:
- static const bool value = IsGarbageCollectedType<T>::value;
+ public:
+ static const bool value = IsGarbageCollectedType<T>::value;
};
-} // namespace WTF
+} // namespace WTF
-#endif // TypeTraits_h
+#endif // TypeTraits_h
« no previous file with comments | « third_party/WebKit/Source/wtf/TriState.h ('k') | third_party/WebKit/Source/wtf/TypeTraits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698