Bug 1625138 - Part 17: Replace mozilla::Decay with std::decay. r=froydnj
authorAndré Bargull <andre.bargull@gmail.com>
Sat, 28 Mar 2020 13:57:15 +0000
changeset 520933 1717b0704c0efb3bcbda26287f91db6dfe83ef80
parent 520932 8bbf59d19fa0b20eb1f0b0b0cc39d0a8e21155c0
child 520934 c690470272399b6c80e9b2ba5ae077028b64a032
push id37260
push userrmaries@mozilla.com
push dateSat, 28 Mar 2020 21:40:49 +0000
treeherdermozilla-central@a177dd13e984 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1625138
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1625138 - Part 17: Replace mozilla::Decay with std::decay. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D68372
dom/media/gmp/ChromiumCDMCallbackProxy.cpp
dom/media/mp4/MP4Metadata.h
dom/promise/Promise-inl.h
ipc/chromium/src/base/task.h
ipc/chromium/src/chrome/common/ipc_message_utils.h
ipc/glue/IPDLParamTraits.h
media/mtransport/runnable_utils.h
mfbt/Tuple.h
mfbt/TypeTraits.h
mfbt/tests/TestTypeTraits.cpp
mozglue/misc/interceptor/Arm64.h
xpcom/threads/MozPromise.h
xpcom/threads/nsThreadUtils.h
--- a/dom/media/gmp/ChromiumCDMCallbackProxy.cpp
+++ b/dom/media/gmp/ChromiumCDMCallbackProxy.cpp
@@ -1,28 +1,30 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ChromiumCDMCallbackProxy.h"
 
+#include <type_traits>
+
 #include "ChromiumCDMProxy.h"
 #include "content_decryption_module.h"
 
 namespace mozilla {
 
 template <class Func, class... Args>
 void ChromiumCDMCallbackProxy::DispatchToMainThread(const char* const aLabel,
                                                     Func aFunc,
                                                     Args&&... aArgs) {
   mMainThread->Dispatch(
-      // Use Decay to ensure all the types are passed by value not by reference.
-      NewRunnableMethod<typename Decay<Args>::Type...>(
-          aLabel, mProxy, aFunc, std::forward<Args>(aArgs)...),
+      // Use decay to ensure all the types are passed by value not by reference.
+      NewRunnableMethod<std::decay_t<Args>...>(aLabel, mProxy, aFunc,
+                                               std::forward<Args>(aArgs)...),
       NS_DISPATCH_NORMAL);
 }
 
 void ChromiumCDMCallbackProxy::SetSessionId(uint32_t aPromiseId,
                                             const nsCString& aSessionId) {
   DispatchToMainThread("ChromiumCDMProxy::OnSetSessionId",
                        &ChromiumCDMProxy::OnSetSessionId, aPromiseId,
                        NS_ConvertUTF8toUTF16(aSessionId));
--- a/dom/media/mp4/MP4Metadata.h
+++ b/dom/media/mp4/MP4Metadata.h
@@ -1,15 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MP4METADATA_H_
 #define MP4METADATA_H_
 
+#include <type_traits>
+
 #include "mozilla/TypeTraits.h"
 #include "mozilla/UniquePtr.h"
 #include "DecoderData.h"
 #include "Index.h"
 #include "MediaData.h"
 #include "MediaInfo.h"
 #include "MediaResult.h"
 #include "ByteStream.h"
@@ -68,17 +70,17 @@ class MP4Metadata : public DecoderDoctor
     ResultAndType(ResultAndType&&) = default;
     ResultAndType& operator=(ResultAndType&&) = default;
 
     mozilla::MediaResult& Result() { return mResult; }
     T& Ref() { return mT; }
 
    private:
     mozilla::MediaResult mResult;
-    typename mozilla::Decay<T>::Type mT;
+    std::decay_t<T> mT;
   };
 
   using ResultAndByteBuffer = ResultAndType<RefPtr<mozilla::MediaByteBuffer>>;
   static ResultAndByteBuffer Metadata(ByteStream* aSource);
 
   static constexpr uint32_t NumberTracksError() { return UINT32_MAX; }
   using ResultAndTrackCount = ResultAndType<uint32_t>;
   ResultAndTrackCount GetNumberTracks(
--- a/dom/promise/Promise-inl.h
+++ b/dom/promise/Promise-inl.h
@@ -2,16 +2,18 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_Promise_inl_h
 #define mozilla_dom_Promise_inl_h
 
+#include <type_traits>
+
 #include "mozilla/TupleCycleCollection.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/dom/PromiseNativeHandler.h"
 
 namespace mozilla {
 namespace dom {
 
@@ -62,17 +64,17 @@ struct StorageTypeHelper<T*, true, false
   using Type = RefPtr<T>;
 };
 
 template <template <typename> class SmartPtr, typename T>
 struct StorageTypeHelper<SmartPtr<T>, true, false>
     : EnableIf<IsConvertible<SmartPtr<T>, T*>::value, RefPtr<T>> {};
 
 template <typename T>
-using StorageType = typename StorageTypeHelper<typename Decay<T>::Type>::Type;
+using StorageType = typename StorageTypeHelper<std::decay_t<T>>::Type;
 
 // Helpers to choose the correct argument type based on the storage type. Smart
 // pointers are converted to the corresponding raw pointer type. Everything else
 // is passed by move reference.
 //
 // Note: We can't just use std::forward for this because the input type may be a
 // raw pointer which does not match the argument type, and while the
 // spec-compliant behavior there should still give us the expected results, MSVC
--- a/ipc/chromium/src/base/task.h
+++ b/ipc/chromium/src/base/task.h
@@ -8,16 +8,17 @@
 #define BASE_TASK_H_
 
 #include "base/revocable_store.h"
 #include "base/tuple.h"
 #include "mozilla/Tuple.h"
 #include "nsISupportsImpl.h"
 #include "nsThreadUtils.h"
 
+#include <type_traits>
 #include <utility>
 
 // Helper functions so that we can call a function a pass it arguments that come
 // from a Tuple.
 
 namespace details {
 
 // Call the given method on the given object. Arguments are passed by move
@@ -132,18 +133,17 @@ class ScopedTaskFactory : public Revocab
 template <class T>
 class ScopedRunnableMethodFactory : public RevocableStore {
  public:
   explicit ScopedRunnableMethodFactory(T* object) : object_(object) {}
 
   template <class Method, typename... Elements>
   inline already_AddRefed<mozilla::Runnable> NewRunnableMethod(
       Method method, Elements&&... elements) {
-    typedef mozilla::Tuple<typename mozilla::Decay<Elements>::Type...>
-        ArgsTuple;
+    typedef mozilla::Tuple<std::decay_t<Elements>...> ArgsTuple;
     typedef RunnableMethod<Method, ArgsTuple> Runnable;
     typedef typename ScopedTaskFactory<Runnable>::TaskWrapper TaskWrapper;
 
     RefPtr<TaskWrapper> task = new TaskWrapper(this);
     task->Init(object_, method,
                mozilla::MakeTuple(std::forward<Elements>(elements)...));
     return task.forget();
   }
@@ -295,17 +295,17 @@ class RunnableMethod : public mozilla::C
 
 namespace dont_add_new_uses_of_this {
 
 // Don't add new uses of this!!!!
 template <class T, class Method, typename... Args>
 inline already_AddRefed<mozilla::Runnable> NewRunnableMethod(T* object,
                                                              Method method,
                                                              Args&&... args) {
-  typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
+  typedef mozilla::Tuple<std::decay_t<Args>...> ArgsTuple;
   RefPtr<mozilla::Runnable> t = new RunnableMethod<T, Method, ArgsTuple>(
       object, method, mozilla::MakeTuple(std::forward<Args>(args)...));
   return t.forget();
 }
 
 }  // namespace dont_add_new_uses_of_this
 
 // RunnableFunction and NewRunnableFunction implementation ---------------------
@@ -333,25 +333,25 @@ class RunnableFunction : public mozilla:
   Function function_;
   Params params_;
 };
 
 template <class Function, typename... Args>
 inline already_AddRefed<mozilla::CancelableRunnable>
 NewCancelableRunnableFunction(const char* name, Function function,
                               Args&&... args) {
-  typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
+  typedef mozilla::Tuple<std::decay_t<Args>...> ArgsTuple;
   RefPtr<mozilla::CancelableRunnable> t =
       new RunnableFunction<Function, ArgsTuple>(
           name, function, mozilla::MakeTuple(std::forward<Args>(args)...));
   return t.forget();
 }
 
 template <class Function, typename... Args>
 inline already_AddRefed<mozilla::Runnable> NewRunnableFunction(
     const char* name, Function function, Args&&... args) {
-  typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
+  typedef mozilla::Tuple<std::decay_t<Args>...> ArgsTuple;
   RefPtr<mozilla::Runnable> t = new RunnableFunction<Function, ArgsTuple>(
       name, function, mozilla::MakeTuple(std::forward<Args>(args)...));
   return t.forget();
 }
 
 #endif  // BASE_TASK_H_
--- a/ipc/chromium/src/chrome/common/ipc_message_utils.h
+++ b/ipc/chromium/src/chrome/common/ipc_message_utils.h
@@ -3,16 +3,17 @@
 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #ifndef CHROME_COMMON_IPC_MESSAGE_UTILS_H_
 #define CHROME_COMMON_IPC_MESSAGE_UTILS_H_
 
 #include <string>
+#include <type_traits>
 #include <vector>
 #include <map>
 
 #include "base/file_path.h"
 #include "base/process.h"
 #include "base/string_util.h"
 #include "base/string16.h"
 #include "base/time.h"
@@ -108,17 +109,17 @@ class MessageIterator {
 // exactly the above idea.
 //
 
 template <class P>
 struct ParamTraits;
 
 template <typename P>
 static inline void WriteParam(Message* m, P&& p) {
-  ParamTraits<typename mozilla::Decay<P>::Type>::Write(m, std::forward<P>(p));
+  ParamTraits<std::decay_t<P>>::Write(m, std::forward<P>(p));
 }
 
 template <typename P>
 static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m,
                                                 PickleIterator* iter, P* p) {
   return ParamTraits<P>::Read(m, iter, p);
 }
 
--- a/ipc/glue/IPDLParamTraits.h
+++ b/ipc/glue/IPDLParamTraits.h
@@ -54,18 +54,18 @@ struct IPDLParamTraits {
 // NOTE: WriteIPDLParam takes a universal reference, so that it can support
 // whatever reference type is supported by the underlying IPDLParamTraits::Write
 // implementation. See the comment on IPDLParamTraits<nsTArray<T>>::Write for
 // more information.
 //
 template <typename P>
 static MOZ_NEVER_INLINE void WriteIPDLParam(IPC::Message* aMsg,
                                             IProtocol* aActor, P&& aParam) {
-  IPDLParamTraits<typename Decay<P>::Type>::Write(aMsg, aActor,
-                                                  std::forward<P>(aParam));
+  IPDLParamTraits<std::decay_t<P>>::Write(aMsg, aActor,
+                                          std::forward<P>(aParam));
 }
 
 template <typename P>
 static MOZ_NEVER_INLINE bool ReadIPDLParam(const IPC::Message* aMsg,
                                            PickleIterator* aIter,
                                            IProtocol* aActor, P* aResult) {
   return IPDLParamTraits<P>::Read(aMsg, aIter, aActor, aResult);
 }
--- a/media/mtransport/runnable_utils.h
+++ b/media/mtransport/runnable_utils.h
@@ -10,16 +10,17 @@
 #define runnable_utils_h__
 
 #include <utility>
 
 #include "mozilla/RefPtr.h"
 #include "nsThreadUtils.h"
 #include <functional>
 #include <tuple>
+#include <type_traits>
 
 // Abstract base class for all of our templates
 namespace mozilla {
 
 namespace detail {
 
 enum RunnableResult { NoResult, ReturnsResult };
 
@@ -68,20 +69,19 @@ class runnable_args_func : public detail
   }
 
  private:
   FunType mFunc;
   std::tuple<Args...> mArgs;
 };
 
 template <typename FunType, typename... Args>
-runnable_args_func<FunType, typename mozilla::Decay<Args>::Type...>*
-WrapRunnableNM(FunType f, Args&&... args) {
-  return new runnable_args_func<FunType,
-                                typename mozilla::Decay<Args>::Type...>(
+runnable_args_func<FunType, std::decay_t<Args>...>* WrapRunnableNM(
+    FunType f, Args&&... args) {
+  return new runnable_args_func<FunType, std::decay_t<Args>...>(
       f, std::forward<Args>(args)...);
 }
 
 template <typename Ret, typename FunType, typename... Args>
 class runnable_args_func_ret
     : public detail::runnable_args_base<detail::ReturnsResult> {
  public:
   template <typename... Arguments>
@@ -95,20 +95,19 @@ class runnable_args_func_ret
 
  private:
   Ret* mReturn;
   FunType mFunc;
   std::tuple<Args...> mArgs;
 };
 
 template <typename R, typename FunType, typename... Args>
-runnable_args_func_ret<R, FunType, typename mozilla::Decay<Args>::Type...>*
-WrapRunnableNMRet(R* ret, FunType f, Args&&... args) {
-  return new runnable_args_func_ret<R, FunType,
-                                    typename mozilla::Decay<Args>::Type...>(
+runnable_args_func_ret<R, FunType, std::decay_t<Args>...>* WrapRunnableNMRet(
+    R* ret, FunType f, Args&&... args) {
+  return new runnable_args_func_ret<R, FunType, std::decay_t<Args>...>(
       ret, f, std::forward<Args>(args)...);
 }
 
 template <typename Class, typename M, typename... Args>
 class runnable_args_memfn
     : public detail::runnable_args_base<detail::NoResult> {
  public:
   template <typename... Arguments>
@@ -121,26 +120,25 @@ class runnable_args_memfn
   void RunInternal() override {
     std::apply(std::mem_fn(mMethod),
                std::tuple_cat(std::tie(mObj), std::move(mArgs)));
   }
 
  private:
   // For holders such as RefPtr and UniquePtr make sure concrete copy is held
   // rather than a potential dangling reference.
-  typename mozilla::Decay<Class>::Type mObj;
+  std::decay_t<Class> mObj;
   M mMethod;
   std::tuple<Args...> mArgs;
 };
 
 template <typename Class, typename M, typename... Args>
-runnable_args_memfn<Class, M, typename mozilla::Decay<Args>::Type...>*
-WrapRunnable(Class&& obj, M method, Args&&... args) {
-  return new runnable_args_memfn<Class, M,
-                                 typename mozilla::Decay<Args>::Type...>(
+runnable_args_memfn<Class, M, std::decay_t<Args>...>* WrapRunnable(
+    Class&& obj, M method, Args&&... args) {
+  return new runnable_args_memfn<Class, M, std::decay_t<Args>...>(
       std::forward<Class>(obj), method, std::forward<Args>(args)...);
 }
 
 template <typename Ret, typename Class, typename M, typename... Args>
 class runnable_args_memfn_ret
     : public detail::runnable_args_base<detail::ReturnsResult> {
  public:
   template <typename... Arguments>
@@ -155,26 +153,25 @@ class runnable_args_memfn_ret
     *mReturn = std::apply(std::mem_fn(mMethod),
                           std::tuple_cat(std::tie(mObj), std::move(mArgs)));
   }
 
  private:
   Ret* mReturn;
   // For holders such as RefPtr and UniquePtr make sure concrete copy is held
   // rather than a potential dangling reference.
-  typename mozilla::Decay<Class>::Type mObj;
+  std::decay_t<Class> mObj;
   M mMethod;
   std::tuple<Args...> mArgs;
 };
 
 template <typename R, typename Class, typename M, typename... Args>
-runnable_args_memfn_ret<R, Class, M, typename mozilla::Decay<Args>::Type...>*
-WrapRunnableRet(R* ret, Class&& obj, M method, Args&&... args) {
-  return new runnable_args_memfn_ret<R, Class, M,
-                                     typename mozilla::Decay<Args>::Type...>(
+runnable_args_memfn_ret<R, Class, M, std::decay_t<Args>...>* WrapRunnableRet(
+    R* ret, Class&& obj, M method, Args&&... args) {
+  return new runnable_args_memfn_ret<R, Class, M, std::decay_t<Args>...>(
       ret, std::forward<Class>(obj), method, std::forward<Args>(args)...);
 }
 
 static inline nsresult RUN_ON_THREAD(
     nsIEventTarget* thread,
     detail::runnable_args_base<detail::NoResult>* runnable, uint32_t flags) {
   return detail::RunOnThreadInternal(
       thread, static_cast<nsIRunnable*>(runnable), flags);
--- a/mfbt/Tuple.h
+++ b/mfbt/Tuple.h
@@ -6,16 +6,17 @@
 
 /* A variadic tuple class. */
 
 #ifndef mozilla_Tuple_h
 #define mozilla_Tuple_h
 
 #include <stddef.h>
 
+#include <type_traits>
 #include <utility>
 
 #include "mozilla/CompactPair.h"
 #include "mozilla/TemplateLib.h"
 #include "mozilla/TypeTraits.h"
 
 namespace mozilla {
 
@@ -453,20 +454,18 @@ void ForEach(Tuple<Elements...>&& aTuple
  * values without specifying the type of the tuple.
  * The type of the tuple is deduced from the types of its elements.
  *
  * Example:
  *
  * auto tuple = MakeTuple(42, 0.5f, 'c');  // has type Tuple<int, float, char>
  */
 template <typename... Elements>
-inline Tuple<typename Decay<Elements>::Type...> MakeTuple(
-    Elements&&... aElements) {
-  return Tuple<typename Decay<Elements>::Type...>(
-      std::forward<Elements>(aElements)...);
+inline Tuple<std::decay_t<Elements>...> MakeTuple(Elements&&... aElements) {
+  return Tuple<std::decay_t<Elements>...>(std::forward<Elements>(aElements)...);
 }
 
 /**
  * A convenience function for constructing a tuple of references to a
  * sequence of variables. Since assignments to the elements of the tuple
  * "go through" to the referenced variables, this can be used to "unpack"
  * a tuple into individual variables.
  *
--- a/mfbt/TypeTraits.h
+++ b/mfbt/TypeTraits.h
@@ -530,50 +530,11 @@ struct Conditional {
   typedef A Type;
 };
 
 template <class A, class B>
 struct Conditional<false, A, B> {
   typedef B Type;
 };
 
-namespace detail {
-
-template <typename U, bool IsArray = IsArray<U>::value,
-          bool IsFunction = IsFunction<U>::value>
-struct DecaySelector;
-
-template <typename U>
-struct DecaySelector<U, false, false> {
-  typedef typename RemoveCV<U>::Type Type;
-};
-
-template <typename U>
-struct DecaySelector<U, true, false> {
-  typedef typename RemoveExtent<U>::Type* Type;
-};
-
-template <typename U>
-struct DecaySelector<U, false, true> {
-  typedef typename AddPointer<U>::Type Type;
-};
-
-};  // namespace detail
-
-/**
- * Strips const/volatile off a type and decays it from an lvalue to an
- * rvalue. So function types are converted to function pointers, arrays to
- * pointers, and references are removed.
- *
- * mozilla::Decay<int>::Type is int
- * mozilla::Decay<int&>::Type is int
- * mozilla::Decay<int&&>::Type is int
- * mozilla::Decay<const int&>::Type is int
- * mozilla::Decay<int[2]>::Type is int*
- * mozilla::Decay<int(int)>::Type is int(*)(int)
- */
-template <typename T>
-class Decay : public detail::DecaySelector<typename RemoveReference<T>::Type> {
-};
-
 } /* namespace mozilla */
 
 #endif /* mozilla_TypeTraits_h */
--- a/mfbt/tests/TestTypeTraits.cpp
+++ b/mfbt/tests/TestTypeTraits.cpp
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Assertions.h"
 #include "mozilla/TypeTraits.h"
 
 using mozilla::AddPointer;
 using mozilla::AddRvalueReference;
-using mozilla::Decay;
 using mozilla::DeclVal;
 using mozilla::IsArray;
 using mozilla::IsConvertible;
 using mozilla::IsDestructible;
 using mozilla::IsFunction;
 using mozilla::IsSame;
 using mozilla::RemoveExtent;
 using mozilla::RemovePointer;
@@ -164,35 +163,16 @@ static_assert(IsSame<AddPointer<int*>::T
               "adding pointer to int* must return int**");
 static_assert(IsSame<AddPointer<int&>::Type, int*>::value,
               "adding pointer to int& must return int*");
 static_assert(IsSame<AddPointer<int* const>::Type, int* const*>::value,
               "adding pointer to int* const must return int* const*");
 static_assert(IsSame<AddPointer<int* volatile>::Type, int* volatile*>::value,
               "adding pointer to int* volatile must return int* volatile*");
 
-static_assert(IsSame<Decay<int>::Type, int>::value,
-              "decaying int must return int");
-static_assert(IsSame<Decay<int*>::Type, int*>::value,
-              "decaying int* must return int*");
-static_assert(IsSame<Decay<int* const>::Type, int*>::value,
-              "decaying int* const must return int*");
-static_assert(IsSame<Decay<int* volatile>::Type, int*>::value,
-              "decaying int* volatile must return int*");
-static_assert(IsSame<Decay<int&>::Type, int>::value,
-              "decaying int& must return int");
-static_assert(IsSame<Decay<const int&>::Type, int>::value,
-              "decaying const int& must return int");
-static_assert(IsSame<Decay<int&&>::Type, int>::value,
-              "decaying int&& must return int");
-static_assert(IsSame<Decay<int[1]>::Type, int*>::value,
-              "decaying int[1] must return int*");
-static_assert(IsSame<Decay<void(int)>::Type, void (*)(int)>::value,
-              "decaying void(int) must return void(*)(int)");
-
 /*
  * Android's broken [u]intptr_t inttype macros are broken because its PRI*PTR
  * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t)
  * is 4 on 32-bit Android. We redefine Android's PRI*PTR macros in
  * IntegerPrintfMacros.h and assert here that our new definitions match the
  * actual type sizes seen at compile time.
  */
 #if defined(ANDROID) && !defined(__LP64__)
--- a/mozglue/misc/interceptor/Arm64.h
+++ b/mozglue/misc/interceptor/Arm64.h
@@ -104,17 +104,17 @@ MFBT_API Result<LoadOrBranch, PCRelCheck
  *                      immediate signed value, including the sign bit.
  */
 template <typename ResultT>
 inline ResultT SignExtend(const uint32_t aValue, const uint8_t aNumValidBits) {
   static_assert(std::is_integral_v<ResultT> && std::is_signed_v<ResultT>,
                 "ResultT must be a signed integral type");
   MOZ_ASSERT(aNumValidBits < 32U && aNumValidBits > 1);
 
-  using UnsignedResultT = typename Decay<std::make_unsigned_t<ResultT>>::Type;
+  using UnsignedResultT = std::decay_t<std::make_unsigned_t<ResultT>>;
 
   const uint8_t kResultWidthBits = sizeof(ResultT) * 8;
 
   // Shift left unsigned
   const uint8_t shiftAmt = kResultWidthBits - aNumValidBits;
   UnsignedResultT shiftedLeft = static_cast<UnsignedResultT>(aValue)
                                 << shiftAmt;
 
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -1430,26 +1430,26 @@ static RefPtr<PromiseType> InvokeAsync(
   static_assert(
       !detail::Any(
           std::is_pointer_v<typename RemoveReference<ActualArgTypes>::Type>...),
       "Cannot pass pointer types through InvokeAsync, Storages must be "
       "provided");
   static_assert(sizeof...(ArgTypes) == sizeof...(ActualArgTypes),
                 "Method's ArgTypes and ActualArgTypes should have equal sizes");
   return detail::InvokeAsyncImpl<
-      StoreCopyPassByRRef<typename Decay<ActualArgTypes>::Type>...>(
+      StoreCopyPassByRRef<std::decay_t<ActualArgTypes>>...>(
       aTarget, aThisVal, aCallerName, aMethod,
       std::forward<ActualArgTypes>(aArgs)...);
 }
 
 namespace detail {
 
 template <typename Function, typename PromiseType>
 class ProxyFunctionRunnable : public CancelableRunnable {
-  typedef typename Decay<Function>::Type FunctionStorage;
+  using FunctionStorage = std::decay_t<Function>;
 
  public:
   template <typename F>
   ProxyFunctionRunnable(typename PromiseType::Private* aProxyPromise,
                         F&& aFunction)
       : CancelableRunnable("detail::ProxyFunctionRunnable"),
         mProxyPromise(aProxyPromise),
         mFunction(new FunctionStorage(std::forward<F>(aFunction))) {}
--- a/xpcom/threads/nsThreadUtils.h
+++ b/xpcom/threads/nsThreadUtils.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsThreadUtils_h__
 #define nsThreadUtils_h__
 
+#include <type_traits>
 #include <utility>
 
 #include "MainThreadUtils.h"
 #include "mozilla/AbstractEventQueue.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/TimeStamp.h"
@@ -883,56 +884,56 @@ struct nsRunnableMethodTraits<PtrType, R
 template <typename T>
 struct IsParameterStorageClass : public mozilla::FalseType {};
 
 // StoreXPassByY structs used to inform nsRunnableMethodArguments how to
 // store arguments, and how to pass them to the target method.
 
 template <typename T>
 struct StoreCopyPassByValue {
-  typedef typename mozilla::Decay<T>::Type stored_type;
+  using stored_type = std::decay_t<T>;
   typedef stored_type passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByValue(A&& a) : m(std::forward<A>(a)) {}
   passed_type PassAsParameter() { return m; }
 };
 template <typename S>
 struct IsParameterStorageClass<StoreCopyPassByValue<S>>
     : public mozilla::TrueType {};
 
 template <typename T>
 struct StoreCopyPassByConstLRef {
-  typedef typename mozilla::Decay<T>::Type stored_type;
+  using stored_type = std::decay_t<T>;
   typedef const stored_type& passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByConstLRef(A&& a) : m(std::forward<A>(a)) {}
   passed_type PassAsParameter() { return m; }
 };
 template <typename S>
 struct IsParameterStorageClass<StoreCopyPassByConstLRef<S>>
     : public mozilla::TrueType {};
 
 template <typename T>
 struct StoreCopyPassByLRef {
-  typedef typename mozilla::Decay<T>::Type stored_type;
+  using stored_type = std::decay_t<T>;
   typedef stored_type& passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByLRef(A&& a) : m(std::forward<A>(a)) {}
   passed_type PassAsParameter() { return m; }
 };
 template <typename S>
 struct IsParameterStorageClass<StoreCopyPassByLRef<S>>
     : public mozilla::TrueType {};
 
 template <typename T>
 struct StoreCopyPassByRRef {
-  typedef typename mozilla::Decay<T>::Type stored_type;
+  using stored_type = std::decay_t<T>;
   typedef stored_type&& passed_type;
   stored_type m;
   template <typename A>
   MOZ_IMPLICIT StoreCopyPassByRRef(A&& a) : m(std::forward<A>(a)) {}
   passed_type PassAsParameter() { return std::move(m); }
 };
 template <typename S>
 struct IsParameterStorageClass<StoreCopyPassByRRef<S>>