Title: [261484] trunk/Source/WTF
Revision
261484
Author
[email protected]
Date
2020-05-11 11:43:15 -0700 (Mon, 11 May 2020)

Log Message

Use alias template for <type_traits> in WTF/wtf/TypeCast.h
https://bugs.webkit.org/show_bug.cgi?id=211714

Patch by Tetsuharu Ohzeki <[email protected]> on 2020-05-11
Reviewed by Darin Adler.

* wtf/TypeCasts.h:
(WTF::TypeCastTraits::isOfType):
(WTF::is):
(WTF::downcast):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (261483 => 261484)


--- trunk/Source/WTF/ChangeLog	2020-05-11 18:28:23 UTC (rev 261483)
+++ trunk/Source/WTF/ChangeLog	2020-05-11 18:43:15 UTC (rev 261484)
@@ -1,3 +1,15 @@
+2020-05-11  Tetsuharu Ohzeki  <[email protected]>
+
+        Use alias template for <type_traits> in WTF/wtf/TypeCast.h
+        https://bugs.webkit.org/show_bug.cgi?id=211714
+
+        Reviewed by Darin Adler.
+
+        * wtf/TypeCasts.h:
+        (WTF::TypeCastTraits::isOfType):
+        (WTF::is):
+        (WTF::downcast):
+
 2020-05-10  Darin Adler  <[email protected]>
 
         Add copy constructor and assignment operator to Ref<>

Modified: trunk/Source/WTF/wtf/TypeCasts.h (261483 => 261484)


--- trunk/Source/WTF/wtf/TypeCasts.h	2020-05-11 18:28:23 UTC (rev 261483)
+++ trunk/Source/WTF/wtf/TypeCasts.h	2020-05-11 18:43:15 UTC (rev 261484)
@@ -29,7 +29,7 @@
 
 namespace WTF {
 
-template <typename ExpectedType, typename ArgType, bool isBaseType = std::is_base_of<ExpectedType, ArgType>::value>
+template <typename ExpectedType, typename ArgType, bool isBaseType = std::is_base_of_v<ExpectedType, ArgType>>
 struct TypeCastTraits {
     static bool isOfType(ArgType&)
     {
@@ -38,7 +38,7 @@
         // TypeCastTraits specialization. Please use the following macro
         // to add that specialization:
         // SPECIALIZE_TYPE_TRAITS_BEGIN() / SPECIALIZE_TYPE_TRAITS_END()
-        static_assert(std::is_void<ExpectedType>::value, "Missing TypeCastTraits specialization");
+        static_assert(std::is_void_v<ExpectedType>, "Missing TypeCastTraits specialization");
         return false;
     }
 };
@@ -54,7 +54,7 @@
 template <typename ExpectedType, typename ArgType>
 inline bool is(ArgType& source)
 {
-    static_assert(std::is_base_of<ArgType, ExpectedType>::value, "Unnecessary type check");
+    static_assert(std::is_base_of_v<ArgType, ExpectedType>, "Unnecessary type check");
     return TypeCastTraits<const ExpectedType, const ArgType>::isOfType(source);
 }
 
@@ -61,7 +61,7 @@
 template <typename ExpectedType, typename ArgType>
 inline bool is(ArgType* source)
 {
-    static_assert(std::is_base_of<ArgType, ExpectedType>::value, "Unnecessary type check");
+    static_assert(std::is_base_of_v<ArgType, ExpectedType>, "Unnecessary type check");
     return source && TypeCastTraits<const ExpectedType, const ArgType>::isOfType(*source);
 }
 
@@ -68,14 +68,14 @@
 // Update T's constness to match Reference's.
 template <typename Reference, typename T>
 using match_constness_t =
-    typename std::conditional<std::is_const<Reference>::value, typename std::add_const<T>::type, typename std::remove_const<T>::type>::type;
+    typename std::conditional_t<std::is_const_v<Reference>, typename std::add_const_t<T>, typename std::remove_const_t<T>>;
 
 // Safe downcasting functions.
 template<typename Target, typename Source>
 inline match_constness_t<Source, Target>& downcast(Source& source)
 {
-    static_assert(!std::is_same<Source, Target>::value, "Unnecessary cast to same type");
-    static_assert(std::is_base_of<Source, Target>::value, "Should be a downcast");
+    static_assert(!std::is_same_v<Source, Target>, "Unnecessary cast to same type");
+    static_assert(std::is_base_of_v<Source, Target>, "Should be a downcast");
     ASSERT_WITH_SECURITY_IMPLICATION(is<Target>(source));
     return static_cast<match_constness_t<Source, Target>&>(source);
 }
@@ -82,8 +82,8 @@
 template<typename Target, typename Source>
 inline match_constness_t<Source, Target>* downcast(Source* source)
 {
-    static_assert(!std::is_same<Source, Target>::value, "Unnecessary cast to same type");
-    static_assert(std::is_base_of<Source, Target>::value, "Should be a downcast");
+    static_assert(!std::is_same_v<Source, Target>, "Unnecessary cast to same type");
+    static_assert(std::is_base_of_v<Source, Target>, "Should be a downcast");
     ASSERT_WITH_SECURITY_IMPLICATION(!source || is<Target>(*source));
     return static_cast<match_constness_t<Source, Target>*>(source);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to