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

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

Issue 1493913004: Remove IsPointerConvertible trait and hacks and just use std::is_base_of. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix #if cond Created 5 years 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/platform/JSONValues.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 f91e99817cc657c71cbeba6fa51e3b89b81ab9a5..c4a8ab85f5e01e02346fd23241f8406a8ba4d29d 100644
--- a/third_party/WebKit/Source/wtf/TypeTraits.h
+++ b/third_party/WebKit/Source/wtf/TypeTraits.h
@@ -23,6 +23,7 @@
#define TypeTraits_h
#include <cstddef>
+#include <type_traits>
#include <utility>
#include "wtf/Compiler.h"
@@ -100,20 +101,6 @@ public:
static const bool value = std::is_integral<T>::value || IsConvertibleToDouble<!std::is_integral<T>::value, T>::value;
};
-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))))
- };
-};
-
template <typename T, typename U> struct IsSameType {
static const bool value = false;
};
@@ -191,10 +178,34 @@ template <typename T> struct IsPolymorphic {
static const bool value = __is_polymorphic(T);
};
+#if COMPILER(MSVC) && !COMPILER(CLANG)
+// FIXME: MSVC bug workaround. Remove once MSVC STL is fixed.
+// C++ 2011 Spec (ISO/IEC 14882:2011(E)) 20.9.6.2 Table 51 states that
+// the template parameters shall be a complete type if they are different types.
+// However, MSVC checks for type completeness even if they are the same type.
+// Here, we use a template specialization for same type case to allow incomplete
+// types.
+
+template <typename T, typename U> class IsBaseOf {
+public:
+ static const bool value = std::is_base_of<T, U>::value;
+};
+
+template <typename T> class IsBaseOf<T, T> {
+public:
+ static const bool value = true;
+};
+
+#define EnsurePtrConvertibleArgDecl(From, To) \
+ typename std::enable_if<WTF::IsBaseOf<To, From>::value>::type* = nullptr
+#define EnsurePtrConvertibleArgDefn(From, To) \
+ typename std::enable_if<WTF::IsBaseOf<To, From>::value>::type*
+#else
#define EnsurePtrConvertibleArgDecl(From, To) \
- typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Type = true
+ typename std::enable_if<std::is_base_of<To, From>::value>::type* = nullptr
#define EnsurePtrConvertibleArgDefn(From, To) \
- typename WTF::EnableIf<WTF::IsPointerConvertible<From, To>::Value, bool>::Type
+ typename std::enable_if<std::is_base_of<To, From>::value>::type*
+#endif
} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/platform/JSONValues.h ('k') | third_party/WebKit/Source/wtf/TypeTraits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698