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

Unified Diff: third_party/WebKit/Source/wtf/TypeTraitsTest.cpp

Issue 2220443004: Use std::is_convertible in EnsurePtrConvertibleArgDecl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: w/ ifdef, w/ test Created 4 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 | « third_party/WebKit/Source/wtf/TypeTraits.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/TypeTraitsTest.cpp
diff --git a/third_party/WebKit/Source/wtf/TypeTraitsTest.cpp b/third_party/WebKit/Source/wtf/TypeTraitsTest.cpp
index 165ec0d5c1c1c24f09562906bec8962e49e9d938..66c82d03ddb703118a5be39a9860595f600e0143 100644
--- a/third_party/WebKit/Source/wtf/TypeTraitsTest.cpp
+++ b/third_party/WebKit/Source/wtf/TypeTraitsTest.cpp
@@ -180,6 +180,42 @@ static_assert(!IsTriviallyDefaultConstructible<DefaultConstructorDeleted>::value
static_assert(!IsTriviallyDestructible<DestructorDeleted>::value,
"DestructorDeleted must not be trivially destructible.");
+template<typename T>
+class Wrapper
+{
+public:
+ template<typename U>
+ Wrapper(const Wrapper<U>&, EnsurePtrConvertibleArgDecl(U, T))
+ {
+ }
+};
+
+class ForwardDeclarationOnlyClass;
+
+static_assert(std::is_convertible<Wrapper<TestDerivedClass>, Wrapper<TestDerivedClass>>::value,
+ "EnsurePtrConvertibleArgDecl<T, T> should pass");
+
+static_assert(std::is_convertible<Wrapper<TestDerivedClass>, Wrapper<const TestDerivedClass>>::value,
+ "EnsurePtrConvertibleArgDecl<T, const T> should pass");
+
+static_assert(!std::is_convertible<Wrapper<const TestDerivedClass>, Wrapper<TestDerivedClass>>::value,
+ "EnsurePtrConvertibleArgDecl<const T, T> should not pass");
+
+static_assert(std::is_convertible<Wrapper<ForwardDeclarationOnlyClass>, Wrapper<ForwardDeclarationOnlyClass>>::value,
+ "EnsurePtrConvertibleArgDecl<T, T> should pass if T is not a complete type");
+
+static_assert(std::is_convertible<Wrapper<ForwardDeclarationOnlyClass>, Wrapper<const ForwardDeclarationOnlyClass>>::value,
+ "EnsurePtrConvertibleArgDecl<T, const T> should pass if T is not a complete type");
+
+static_assert(!std::is_convertible<Wrapper<const ForwardDeclarationOnlyClass>, Wrapper<ForwardDeclarationOnlyClass>>::value,
+ "EnsurePtrConvertibleArgDecl<const T, T> should not pass if T is not a complete type");
+
+static_assert(std::is_convertible<Wrapper<TestDerivedClass>, Wrapper<TestBaseClass<int>>>::value,
+ "EnsurePtrConvertibleArgDecl<U, T> should pass if U is a subclass of T");
+
+static_assert(!std::is_convertible<Wrapper<TestBaseClass<int>>, Wrapper<TestDerivedClass>>::value,
+ "EnsurePtrConvertibleArgDecl<U, T> should not pass if U is a base class of T");
+
} // anonymous namespace
} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/TypeTraits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698