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

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

Issue 2000673003: Split out Members, Persistents and SelfKeepAlive in separate headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Phase out blink::IsGarbageCollectedType<T> Created 4 years, 7 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 | « third_party/WebKit/Source/wtf/Functional.h ('k') | no next file » | 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 e3c91191fe0fa1294d01edba511de1eab30e5758..10bf12d72f20ac2932ad9ddc504268cbf1514cdd 100644
--- a/third_party/WebKit/Source/wtf/TypeTraits.h
+++ b/third_party/WebKit/Source/wtf/TypeTraits.h
@@ -300,10 +300,23 @@ class IsGarbageCollectedType {
char padding[8];
} NoType;
+ static_assert(sizeof(T), "T must be fully defined");
+
+ using NonConstType = typename std::remove_const<T>::type;
template <typename U> static YesType checkGarbageCollectedType(typename U::IsGarbageCollectedTypeMarker*);
template <typename U> static NoType checkGarbageCollectedType(...);
+
+ template <typename U> static YesType checkGarbageCollectedMixinType(typename U::IsGarbageCollectedMixinMarker*);
+ template <typename U> static NoType checkGarbageCollectedMixinType(...);
public:
- static const bool value = (sizeof(YesType) == sizeof(checkGarbageCollectedType<T>(nullptr)));
+ static const bool value = (sizeof(YesType) == sizeof(checkGarbageCollectedType<NonConstType>(nullptr)))
+ || (sizeof(YesType) == sizeof(checkGarbageCollectedMixinType<NonConstType>(nullptr)));
+};
+
+template<>
+class IsGarbageCollectedType<void> {
+public:
+ static const bool value = false;
};
template<typename T>
@@ -319,17 +332,20 @@ public:
static const bool value = (sizeof(YesType) == sizeof(checkPersistentReferenceType<T>(nullptr)));
};
-template<typename T>
+template<typename T, bool = std::is_function<typename std::remove_const<typename std::remove_pointer<T>::type>::type>::value || std::is_void<typename std::remove_const<typename std::remove_pointer<T>::type>::type>::value>
class IsPointerToGarbageCollectedType {
public:
static const bool value = false;
};
+
template<typename T>
-class IsPointerToGarbageCollectedType<T*> {
+class IsPointerToGarbageCollectedType<T*, false> {
public:
static const bool value = IsGarbageCollectedType<T>::value;
};
} // namespace WTF
+using WTF::IsGarbageCollectedType;
+
#endif // TypeTraits_h
« no previous file with comments | « third_party/WebKit/Source/wtf/Functional.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698