Modified: trunk/Source/WTF/ChangeLog (261464 => 261465)
--- trunk/Source/WTF/ChangeLog 2020-05-11 02:36:05 UTC (rev 261464)
+++ trunk/Source/WTF/ChangeLog 2020-05-11 04:46:12 UTC (rev 261465)
@@ -1,3 +1,13 @@
+2020-05-10 Tetsuharu Ohzeki <[email protected]>
+
+ Use alias template to define `match_constness_t` in Wtf/wtp/TypeCasts.h
+ https://bugs.webkit.org/show_bug.cgi?id=211698
+
+ Reviewed by Yusuke Suzuki.
+
+ * wtf/TypeCasts.h:
+ (WTF::downcast):
+
2020-05-10 Basuke Suzuki <[email protected]>
Add ENABLE_PERIODIC_MEMORY_MONITOR flag.
Modified: trunk/Source/WTF/wtf/TypeCasts.h (261464 => 261465)
--- trunk/Source/WTF/wtf/TypeCasts.h 2020-05-11 02:36:05 UTC (rev 261464)
+++ trunk/Source/WTF/wtf/TypeCasts.h 2020-05-11 04:46:12 UTC (rev 261465)
@@ -67,26 +67,25 @@
// Update T's constness to match Reference's.
template <typename Reference, typename T>
-struct match_constness {
- typedef typename std::conditional<std::is_const<Reference>::value, typename std::add_const<T>::type, typename std::remove_const<T>::type>::type type;
-};
+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;
// Safe downcasting functions.
template<typename Target, typename Source>
-inline typename match_constness<Source, Target>::type& downcast(Source& 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");
ASSERT_WITH_SECURITY_IMPLICATION(is<Target>(source));
- return static_cast<typename match_constness<Source, Target>::type&>(source);
+ return static_cast<match_constness_t<Source, Target>&>(source);
}
template<typename Target, typename Source>
-inline typename match_constness<Source, Target>::type* downcast(Source* 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");
ASSERT_WITH_SECURITY_IMPLICATION(!source || is<Target>(*source));
- return static_cast<typename match_constness<Source, Target>::type*>(source);
+ return static_cast<match_constness_t<Source, Target>*>(source);
}
// Add support for type checking / casting using is<>() / downcast<>() helpers for a specific class.