Bug 1298337 - Replace RemoveXXX series of type traits with std version in current codebase. r?froydnj draft
authorJames Cheng <jacheng@mozilla.com>
Fri, 26 Aug 2016 17:37:14 +0800
changeset 406005 39f68702c857af2bdc25d6c03e92f422022ba662
parent 405855 a551f534773cf2d6933f78ce7d82a7a33a99643e
child 529566 5d9ba79aabbbacdcfd9f2d4daf165c0232b3ad9a
push id27628
push userbmo:jacheng@mozilla.com
push dateFri, 26 Aug 2016 09:43:31 +0000
reviewersfroydnj
bugs1298337
milestone51.0a1
Bug 1298337 - Replace RemoveXXX series of type traits with std version in current codebase. r?froydnj MozReview-Commit-ID: 7K90QTuuPLn
dom/media/MediaEventSource.h
dom/media/gmp/GMPDecryptorChild.cpp
ipc/glue/ProtocolUtils.cpp
js/public/HashTable.h
js/src/gc/Marking.cpp
js/src/gc/Policy.h
js/src/jshashutil.h
js/src/threading/Thread.h
mfbt/Maybe.h
mfbt/Pair.h
mfbt/UniquePtr.h
mfbt/UniquePtrExtensions.h
mfbt/Variant.h
xpcom/glue/nsTArray.h
xpcom/glue/nsThreadUtils.h
--- a/dom/media/MediaEventSource.h
+++ b/dom/media/MediaEventSource.h
@@ -2,16 +2,18 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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 MediaEventSource_h_
 #define MediaEventSource_h_
 
+#include <type_traits>
+
 #include "mozilla/AbstractThread.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/IndexSequence.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Tuple.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/UniquePtr.h"
 
@@ -185,17 +187,17 @@ class ListenerHelper {
       return NS_OK;
     }
 
   private:
     RefPtr<RevocableToken> mToken;
     Function mFunction;
 
     template <typename T>
-    using ArgType = typename RemoveCV<typename RemoveReference<T>::Type>::Type;
+    using ArgType = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
     Tuple<ArgType<Ts>...> mEvents;
   };
 
 public:
   ListenerHelper(RevocableToken* aToken, Target* aTarget, const Function& aFunc)
     : mToken(aToken), mTarget(aTarget), mFunction(aFunc) {}
 
   // |F| takes one or more arguments.
--- a/dom/media/gmp/GMPDecryptorChild.cpp
+++ b/dom/media/gmp/GMPDecryptorChild.cpp
@@ -1,21 +1,23 @@
 /* -*- 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 <ctime>
+#include <type_traits>
+
 #include "GMPDecryptorChild.h"
 #include "GMPContentChild.h"
 #include "GMPChild.h"
 #include "base/task.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Unused.h"
 #include "runnable_utils.h"
-#include <ctime>
 
 #define ON_GMP_THREAD() (mPlugin->GMPMessageLoop() == MessageLoop::current())
 
 #define CALL_ON_GMP_THREAD(_func, ...) \
   CallOnGMPThread(&GMPDecryptorChild::_func, __VA_ARGS__)
 
 namespace mozilla {
 namespace gmp {
@@ -43,17 +45,17 @@ GMPDecryptorChild::CallMethod(MethodType
   // Don't send IPC messages after tear-down.
   if (mSession) {
     (this->*aMethod)(Forward<ParamType>(aParams)...);
   }
 }
 
 template<typename T>
 struct AddConstReference {
-  typedef const typename RemoveReference<T>::Type& Type;
+  typedef const typename std::remove_reference<T>::type& Type;
 };
 
 template<typename MethodType, typename... ParamType>
 void
 GMPDecryptorChild::CallOnGMPThread(MethodType aMethod, ParamType&&... aParams)
 {
   if (ON_GMP_THREAD()) {
     // Use forwarding reference when we can.
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -19,39 +19,39 @@
 #include "nsPrintfCString.h"
 
 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
 #define TARGET_SANDBOX_EXPORTS
 #include "mozilla/sandboxTarget.h"
 #endif
 
 #if defined(MOZ_CRASHREPORTER) && defined(XP_WIN)
+#include <type_traits>
+
 #include "aclapi.h"
 #include "sddl.h"
-
-#include "mozilla/TypeTraits.h"
 #endif
 
 #include "nsAutoPtr.h"
 
 using namespace IPC;
 
 using base::GetCurrentProcId;
 using base::ProcessHandle;
 using base::ProcessId;
 
 namespace mozilla {
 
 #if defined(MOZ_CRASHREPORTER) && defined(XP_WIN)
 // Generate RAII classes for LPTSTR and PSECURITY_DESCRIPTOR.
 MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedLPTStr, \
-                                          RemovePointer<LPTSTR>::Type, \
+                                          std::remove_pointer<LPTSTR>::type, \
                                           ::LocalFree)
 MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPSecurityDescriptor, \
-                                          RemovePointer<PSECURITY_DESCRIPTOR>::Type, \
+                                          std::remove_pointer<PSECURITY_DESCRIPTOR>::type, \
                                           ::LocalFree)
 #endif
 
 namespace ipc {
 
 ProtocolCloneContext::ProtocolCloneContext()
   : mNeckoParent(nullptr)
 {}
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -2,16 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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 js_HashTable_h
 #define js_HashTable_h
 
+#include <type_traits>
+
 #include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Casting.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/Opaque.h"
@@ -776,17 +778,17 @@ namespace detail {
 
 template <class T, class HashPolicy, class AllocPolicy>
 class HashTable;
 
 template <class T>
 class HashTableEntry
 {
     template <class, class, class> friend class HashTable;
-    typedef typename mozilla::RemoveConst<T>::Type NonConstT;
+    typedef typename std::remove_const<T>::type NonConstT;
 
     HashNumber keyHash;
     mozilla::AlignedStorage2<NonConstT> mem;
 
     static const HashNumber sFreeKey = 0;
     static const HashNumber sRemovedKey = 1;
     static const HashNumber sCollisionBit = 1;
 
@@ -850,17 +852,17 @@ class HashTableEntry
     }
 };
 
 template <class T, class HashPolicy, class AllocPolicy>
 class HashTable : private AllocPolicy
 {
     friend class mozilla::ReentrancyGuard;
 
-    typedef typename mozilla::RemoveConst<T>::Type NonConstT;
+    typedef typename std::remove_const<T>::type NonConstT;
     typedef typename HashPolicy::KeyType Key;
     typedef typename HashPolicy::Lookup Lookup;
 
   public:
     typedef HashTableEntry<T> Entry;
 
     // A nullable pointer to a hash table element. A Ptr |p| can be tested
     // either explicitly |if (p.found()) p->...| or using boolean conversion
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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 "gc/Marking.h"
 
+#include <type_traits>
+
 #include "mozilla/DebugOnly.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ReentrancyGuard.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/TypeTraits.h"
 
 #include "jsgc.h"
 #include "jsprf.h"
@@ -835,17 +837,17 @@ NoteWeakEdge(GCMarker* gcmarker, T* thin
 {
     MOZ_CRASH("the gc does not support tagged pointers as weak edges");
 }
 
 template <typename T>
 void
 js::GCMarker::noteWeakEdge(T* edge)
 {
-    static_assert(IsBaseOf<Cell, typename mozilla::RemovePointer<T>::Type>::value,
+    static_assert(IsBaseOf<Cell, typename std::remove_pointer<T>::type>::value,
                   "edge must point to a GC pointer");
     MOZ_ASSERT((*edge)->isTenured());
 
     // Note: we really want the *source* Zone here. The edge may start in a
     // non-gc heap location, however, so we use the fact that cross-zone weak
     // references are not allowed and use the *target's* zone.
     JS::Zone::WeakEdges &weakRefs = (*edge)->asTenured().zone()->gcWeakRefs;
     AutoEnterOOMUnsafeRegion oomUnsafe;
--- a/js/src/gc/Policy.h
+++ b/js/src/gc/Policy.h
@@ -4,17 +4,17 @@
  * 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/. */
 
 /* JS Garbage Collector. */
 
 #ifndef gc_Policy_h
 #define gc_Policy_h
 
-#include "mozilla/TypeTraits.h"
+#include <type_traits>
 #include "gc/Barrier.h"
 #include "gc/Marking.h"
 #include "js/GCPolicyAPI.h"
 
 // Forward declare the types we're defining policies for. This file is
 // included in all places that define GC things, so the real definitions
 // will be available when we do template expansion, allowing for use of
 // static members in the underlying types. We cannot, however, use
@@ -125,17 +125,17 @@ class JitCode;
     FOR_EACH_INTERNAL_GC_POINTER_TYPE(D) \
     FOR_EACH_INTERNAL_TAGGED_GC_POINTER_TYPE(D)
 
 namespace js {
 
 // Define the GCPolicy for all internal pointers.
 template <typename T>
 struct InternalGCPointerPolicy {
-    using Type = typename mozilla::RemovePointer<T>::Type;
+    using Type = typename std::remove_pointer<T>::type;
     static T initial() { return nullptr; }
     static void preBarrier(T v) { Type::writeBarrierPre(v); }
     static void postBarrier(T* vp, T prev, T next) { Type::writeBarrierPost(vp, prev, next); }
     static void readBarrier(T v) { Type::readBarrier(v); }
     static void trace(JSTracer* trc, T* vp, const char* name) {
         TraceManuallyBarrieredEdge(trc, vp, name);
     }
 };
--- a/js/src/jshashutil.h
+++ b/js/src/jshashutil.h
@@ -2,16 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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 jshashutil_h
 #define jshashutil_h
 
+#include <type_traits>
+
 #include "jscntxt.h"
 
 #include "gc/Zone.h"
 
 namespace js {
 
 /*
  * Used to add entries to a js::HashMap or HashSet where the key depends on a GC
@@ -70,17 +72,17 @@ struct DependentAddPtr
     DependentAddPtr() = delete;
     DependentAddPtr(const DependentAddPtr&) = delete;
     DependentAddPtr& operator=(const DependentAddPtr&) = delete;
 };
 
 template <typename T, typename Lookup>
 inline auto
 MakeDependentAddPtr(const ExclusiveContext* cx, T& table, const Lookup& lookup)
-  -> DependentAddPtr<typename mozilla::RemoveReference<decltype(table)>::Type>
+  -> DependentAddPtr<typename std::remove_reference<decltype(table)>::type>
 {
-    using Ptr = DependentAddPtr<typename mozilla::RemoveReference<decltype(table)>::Type>;
+    using Ptr = DependentAddPtr<typename std::remove_reference<decltype(table)>::type>;
     return Ptr(cx, table, lookup);
 }
 
 } // namespace js
 
 #endif
--- a/js/src/threading/Thread.h
+++ b/js/src/threading/Thread.h
@@ -2,25 +2,26 @@
 /* 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 threading_Thread_h
 #define threading_Thread_h
 
+#include <type_traits>
+#include <stdint.h>
+
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/IndexSequence.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Tuple.h"
 
-#include <stdint.h>
-
 #include "js/Utility.h"
 
 #ifdef XP_WIN
 # define THREAD_RETURN_TYPE unsigned int
 # define THREAD_CALL_API __stdcall
 #else
 # define THREAD_RETURN_TYPE void*
 # define THREAD_CALL_API
@@ -85,18 +86,18 @@ public:
   };
 
   // Create a Thread in an initially unjoinable state. A thread of execution can
   // be created for this Thread by calling |init|. Some of the thread's
   // properties may be controlled by passing options to this constructor.
   template <typename O = Options,
             // SFINAE to make sure we don't try and treat functors for the other
             // constructor as an Options and vice versa.
-            typename NonConstO = typename mozilla::RemoveConst<O>::Type,
-            typename DerefO = typename mozilla::RemoveReference<NonConstO>::Type,
+            typename NonConstO = typename std::remove_const<O>::type,
+            typename DerefO = typename std::remove_reference<NonConstO>::type,
             typename = typename mozilla::EnableIf<mozilla::IsSame<DerefO, Options>::value,
                                                   void*>::Type>
   explicit Thread(O&& options = Options())
     : id_(Id())
     , options_(mozilla::Forward<O>(options))
   { }
 
   // Start a thread of execution at functor |f| with parameters |args|. Note
--- a/mfbt/Maybe.h
+++ b/mfbt/Maybe.h
@@ -4,23 +4,23 @@
  * 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/. */
 
 /* A class for optional values and in-place lazy construction. */
 
 #ifndef mozilla_Maybe_h
 #define mozilla_Maybe_h
 
+#include <new>  // for placement new
+#include <type_traits>
+
 #include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Move.h"
-#include "mozilla/TypeTraits.h"
-
-#include <new>  // for placement new
 
 namespace mozilla {
 
 struct Nothing { };
 
 /*
  * Maybe is a container class which contains either zero or one elements. It
  * serves two roles. It can represent values which are *semantically* optional,
@@ -398,27 +398,27 @@ public:
  *
  * Some() selects the type of Maybe it returns by removing any const, volatile,
  * or reference qualifiers from the type of the value you pass to it. This gives
  * it more intuitive behavior when used in expressions, but it also means that
  * if you need to construct a Maybe value that holds a const, volatile, or
  * reference value, you need to use emplace() instead.
  */
 template<typename T>
-Maybe<typename RemoveCV<typename RemoveReference<T>::Type>::Type>
+Maybe<typename std::remove_cv<typename std::remove_reference<T>::type>::type>
 Some(T&& aValue)
 {
-  typedef typename RemoveCV<typename RemoveReference<T>::Type>::Type U;
+  typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type U;
   Maybe<U> value;
   value.emplace(Forward<T>(aValue));
   return value;
 }
 
 template<typename T>
-Maybe<typename RemoveCV<typename RemoveReference<T>::Type>::Type>
+Maybe<typename std::remove_cv<typename std::remove_reference<T>::type>::type>
 ToMaybe(T* aPtr)
 {
   if (aPtr) {
     return Some(*aPtr);
   }
   return Nothing();
 }
 
--- a/mfbt/Pair.h
+++ b/mfbt/Pair.h
@@ -4,16 +4,18 @@
  * 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/. */
 
 /* A class holding a pair of objects that tries to conserve storage space. */
 
 #ifndef mozilla_Pair_h
 #define mozilla_Pair_h
 
+#include <type_traits>
+
 #include "mozilla/Attributes.h"
 #include "mozilla/Move.h"
 #include "mozilla/TypeTraits.h"
 
 namespace mozilla {
 
 namespace detail {
 
@@ -198,22 +200,22 @@ Swap(Pair<A, B>& aX, Pair<A, B>& aY)
  * MakePair allows you to construct a Pair instance using type inference. A call
  * like this:
  *
  *   MakePair(Foo(), Bar())
  *
  * will return a Pair<Foo, Bar>.
  */
 template<typename A, typename B>
-Pair<typename RemoveCV<typename RemoveReference<A>::Type>::Type,
-     typename RemoveCV<typename RemoveReference<B>::Type>::Type>
+Pair<typename std::remove_cv<typename std::remove_reference<A>::type>::type,
+     typename std::remove_cv<typename std::remove_reference<B>::type>::type>
 MakePair(A&& aA, B&& aB)
 {
   return
-    Pair<typename RemoveCV<typename RemoveReference<A>::Type>::Type,
-         typename RemoveCV<typename RemoveReference<B>::Type>::Type>(
+    Pair<typename std::remove_cv<typename std::remove_reference<A>::type>::type,
+         typename std::remove_cv<typename std::remove_reference<B>::type>::type>(
              Forward<A>(aA),
              Forward<B>(aB));
 }
 
 } // namespace mozilla
 
 #endif /* mozilla_Pair_h */
--- a/mfbt/UniquePtr.h
+++ b/mfbt/UniquePtr.h
@@ -4,16 +4,17 @@
  * 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/. */
 
 /* Smart pointer managing sole ownership of a resource. */
 
 #ifndef mozilla_UniquePtr_h
 #define mozilla_UniquePtr_h
 
+#include <type_traits>
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Compiler.h"
 #include "mozilla/Move.h"
 #include "mozilla/Pair.h"
 #include "mozilla/TypeTraits.h"
 
 namespace mozilla {
@@ -48,17 +49,17 @@ template <class T, class D>
 struct PointerTypeImpl<T, D, false>
 {
   typedef T* Type;
 };
 
 template <class T, class D>
 struct PointerType
 {
-  typedef typename PointerTypeImpl<T, typename RemoveReference<D>::Type>::Type Type;
+  typedef typename PointerTypeImpl<T, typename std::remove_reference<D>::type>::Type Type;
 };
 
 } // namespace detail
 
 /**
  * UniquePtr is a smart pointer that wholly owns a resource.  Ownership may be
  * transferred out of a UniquePtr through explicit action, but otherwise the
  * resource is destroyed when the UniquePtr is destroyed.
@@ -247,17 +248,17 @@ public:
   //     void operator()(void* aPtr) { free(aPtr); }
   //   };
   //
   // If deletion really, truly, must be a variable: you might be able to work
   // around this with a deleter class that contains the function reference.
   // But this workaround is untried and untested, because variable deletion
   // behavior really isn't something you should use.
   UniquePtr(Pointer aPtr,
-            typename RemoveReference<D>::Type&& aD2)
+            typename std::remove_reference<D>::type&& aD2)
     : mTuple(aPtr, Move(aD2))
   {
     static_assert(!IsReference<D>::value,
                   "rvalue deleter can't be stored by reference");
   }
 
   UniquePtr(UniquePtr&& aOther)
     : mTuple(aOther.release(), Forward<DeleterType>(aOther.get_deleter()))
@@ -408,17 +409,17 @@ public:
     : mTuple(aPtr, aD1)
   {}
 
   // If you encounter an error with MSVC10 about RemoveReference below, along
   // the lines that "more than one partial specialization matches the template
   // argument list": don't use UniquePtr<T[], reference to function>!  See the
   // comment by this constructor in the non-T[] specialization above.
   UniquePtr(Pointer aPtr,
-            typename RemoveReference<D>::Type&& aD2)
+            typename std::remove_reference<D>::type&& aD2)
     : mTuple(aPtr, Move(aD2))
   {
     static_assert(!IsReference<D>::value,
                   "rvalue deleter can't be stored by reference");
   }
 
   // Forbidden for the same reasons as stated above.
   template<typename U, typename V>
@@ -679,17 +680,17 @@ MakeUnique(Args&&... aArgs)
 {
   return UniquePtr<T>(new T(Forward<Args>(aArgs)...));
 }
 
 template<typename T>
 typename detail::UniqueSelector<T>::UnknownBound
 MakeUnique(decltype(sizeof(int)) aN)
 {
-  typedef typename RemoveExtent<T>::Type ArrayType;
+  typedef typename std::remove_extent<T>::type ArrayType;
   return UniquePtr<T>(new ArrayType[aN]());
 }
 
 template<typename T, typename... Args>
 typename detail::UniqueSelector<T>::KnownBound
 MakeUnique(Args&&... aArgs) = delete;
 
 } // namespace mozilla
--- a/mfbt/UniquePtrExtensions.h
+++ b/mfbt/UniquePtrExtensions.h
@@ -24,17 +24,17 @@ MakeUniqueFallible(Args&&... aArgs)
 {
   return UniquePtr<T>(new (fallible) T(Forward<Args>(aArgs)...));
 }
 
 template<typename T>
 typename detail::UniqueSelector<T>::UnknownBound
 MakeUniqueFallible(decltype(sizeof(int)) aN)
 {
-  typedef typename RemoveExtent<T>::Type ArrayType;
+  typedef typename std::remove_extent<T>::type ArrayType;
   return UniquePtr<T>(new (fallible) ArrayType[aN]());
 }
 
 template<typename T, typename... Args>
 typename detail::UniqueSelector<T>::KnownBound
 MakeUniqueFallible(Args&&... aArgs) = delete;
 
 namespace detail {
--- a/mfbt/Variant.h
+++ b/mfbt/Variant.h
@@ -3,16 +3,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/. */
 
 /* A template class for tagged unions. */
 
 #include <new>
 #include <stdint.h>
+#include <type_traits>
 
 #include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Move.h"
 #include "mozilla/TypeTraits.h"
 
 #ifndef mozilla_Variant_h
 #define mozilla_Variant_h
@@ -102,17 +103,17 @@ struct SelectVariantTypeHelper<T, Head, 
 
 /**
  * SelectVariantType takes a type T and a list of variant types Variants and
  * yields a type Type, selected from Variants, that can store a value of type T
  * or a reference to type T. If no such type was found, Type is not defined.
  */
 template <typename T, typename... Variants>
 struct SelectVariantType
-  : public SelectVariantTypeHelper<typename RemoveConst<typename RemoveReference<T>::Type>::Type,
+  : public SelectVariantTypeHelper<typename std::remove_const<typename std::remove_reference<T>::type>::type,
                                    Variants...>
 { };
 
 // Compute a fast, compact type that can be used to hold integral values that
 // distinctly map to every type in Ts.
 template<typename... Ts>
 struct VariantTag
 {
@@ -298,17 +299,17 @@ struct AsVariantTemporary
   AsVariantTemporary(AsVariantTemporary&& aOther)
     : mValue(Move(aOther.mValue))
   {}
 
   AsVariantTemporary() = delete;
   void operator=(const AsVariantTemporary&) = delete;
   void operator=(AsVariantTemporary&&) = delete;
 
-  typename RemoveConst<typename RemoveReference<T>::Type>::Type mValue;
+  typename std::remove_const<typename std::remove_reference<T>::type>::type mValue;
 };
 
 } // namespace detail
 
 /**
  * # mozilla::Variant
  *
  * A variant / tagged union / heterogenous disjoint union / sum-type template
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -2,40 +2,41 @@
 /* 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 nsTArray_h__
 #define nsTArray_h__
 
+#include <new>
+#include <type_traits>
+#include <string.h>
+
 #include "nsTArrayForwardDeclare.h"
 #include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/BinarySearch.h"
 #include "mozilla/fallible.h"
 #include "mozilla/Function.h"
 #include "mozilla/InitializerList.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/ReverseIterator.h"
 #include "mozilla/TypeTraits.h"
 
-#include <string.h>
-
 #include "nsCycleCollectionNoteChild.h"
 #include "nsAlgorithm.h"
 #include "nscore.h"
 #include "nsQuickSort.h"
 #include "nsDebug.h"
 #include "nsISupportsImpl.h"
 #include "nsRegionFwd.h"
-#include <new>
 
 namespace JS {
 template<class T>
 class Heap;
 } /* namespace JS */
 
 class nsRegion;
 namespace mozilla {
@@ -541,18 +542,18 @@ public:
     // and people don't expect it; nsTArray should work like a regular
     // C/C++ array in this respect.
     new (static_cast<void*>(aE)) E;
   }
   // Invoke the copy-constructor in place.
   template<class A>
   static inline void Construct(E* aE, A&& aArg)
   {
-    typedef typename mozilla::RemoveCV<E>::Type E_NoCV;
-    typedef typename mozilla::RemoveCV<A>::Type A_NoCV;
+    typedef typename std::remove_cv<E>::type E_NoCV;
+    typedef typename std::remove_cv<A>::type A_NoCV;
     static_assert(!mozilla::IsSame<E_NoCV*, A_NoCV>::value,
                   "For safety, we disallow constructing nsTArray<E> elements "
                   "from E* pointers. See bug 960591.");
     new (static_cast<void*>(aE)) E(mozilla::Forward<A>(aArg));
   }
   // Invoke the destructor in place.
   static inline void Destruct(E* aE) { aE->~E(); }
 };
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/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 "prthread.h"
 #include "prinrval.h"
 #include "MainThreadUtils.h"
 #include "nsIThreadManager.h"
 #include "nsIThread.h"
 #include "nsIRunnable.h"
 #include "nsICancelableRunnable.h"
 #include "nsStringGlue.h"
@@ -287,17 +288,17 @@ private:
 } // namespace mozilla
 
 template<typename Function>
 already_AddRefed<mozilla::Runnable>
 NS_NewRunnableFunction(Function&& aFunction)
 {
   return do_AddRef(new mozilla::detail::RunnableFunction
                    // Make sure we store a non-reference in nsRunnableFunction.
-                   <typename mozilla::RemoveReference<Function>::Type>
+                   <typename std::remove_reference<Function>::type>
                    // But still forward aFunction to move if possible.
                    (mozilla::Forward<Function>(aFunction)));
 }
 
 // An event that can be used to call a method on a class.  The class type must
 // support reference counting. This event supports Revoke for use
 // with nsRevocableEventPtr.
 template<class ClassType,
@@ -575,17 +576,17 @@ struct IsParameterStorageClass<StoreCopy
   : public mozilla::TrueType {};
 
 namespace detail {
 
 template<typename TWithoutPointer>
 struct NonnsISupportsPointerStorageClass
   : mozilla::Conditional<mozilla::IsConst<TWithoutPointer>::value,
                          StoreConstPtrPassByConstPtr<
-                           typename mozilla::RemoveConst<TWithoutPointer>::Type>,
+                           typename std::remove_const<TWithoutPointer>::type>,
                          StorePtrPassByPtr<TWithoutPointer>>
 {};
 
 template<typename>
 struct SFINAE1True : mozilla::TrueType
 {};
 
 template<class T>
@@ -637,50 +638,50 @@ struct PointerStorageClass
                            TWithoutPointer
                          >::Type>
 {};
 
 template<typename TWithoutRef>
 struct LValueReferenceStorageClass
   : mozilla::Conditional<mozilla::IsConst<TWithoutRef>::value,
                          StoreConstRefPassByConstLRef<
-                           typename mozilla::RemoveConst<TWithoutRef>::Type>,
+                           typename std::remove_const<TWithoutRef>::type>,
                          StoreRefPassByLRef<TWithoutRef>>
 {};
 
 template<typename T>
 struct SmartPointerStorageClass
   : mozilla::Conditional<IsRefcountedSmartPointer<T>::value,
                          StorensRefPtrPassByPtr<
                            typename StripSmartPointer<T>::Type>,
                          StoreCopyPassByValue<T>>
 {};
 
 template<typename T>
 struct NonLValueReferenceStorageClass
   : mozilla::Conditional<mozilla::IsRvalueReference<T>::value,
                          StoreCopyPassByRRef<
-                           typename mozilla::RemoveReference<T>::Type>,
+                           typename std::remove_reference<T>::type>,
                          typename SmartPointerStorageClass<T>::Type>
 {};
 
 template<typename T>
 struct NonPointerStorageClass
   : mozilla::Conditional<mozilla::IsLvalueReference<T>::value,
                          typename LValueReferenceStorageClass<
-                           typename mozilla::RemoveReference<T>::Type
+                           typename std::remove_reference<T>::type
                          >::Type,
                          typename NonLValueReferenceStorageClass<T>::Type>
 {};
 
 template<typename T>
 struct NonParameterStorageClass
   : mozilla::Conditional<mozilla::IsPointer<T>::value,
                          typename PointerStorageClass<
-                           typename mozilla::RemovePointer<T>::Type
+                           typename std::remove_pointer<T>::type
                          >::Type,
                          typename NonPointerStorageClass<T>::Type>
 {};
 
 // Choose storage&passing strategy based on preferred storage type:
 // - If IsParameterStorageClass<T>::value is true, use as-is.
 // - RC*       -> StorensRefPtrPassByPtr<RC>     : Store RefPtr<RC>, pass RC*
 //   ^^ RC quacks like a ref-counted type (i.e., has AddRef and Release methods)