Bug 1434710 - Replaced all instances of mozilla::IndexSequence, mozilla::MakeIndexSequence and mozilla::IndexSequenceFor with std::index_sequence, std::make_index_sequence and std::index_sequence_for and removed mfbt/IndexSequence.h. r=botond
authorTom Bannister <tomabann@gmail.com>
Mon, 09 Apr 2018 21:12:13 +1000
changeset 413281 afb4d1027523994854883d7e1601a3dac8dfe6b3
parent 413280 eb8002dda30c2c2cdd60c3bb4d1e563e6393d98a
child 413282 b12b7c5b8178c5a00f911a5e12cc036eddd7601a
push id33842
push usernerli@mozilla.com
push dateSat, 14 Apr 2018 09:47:52 +0000
treeherdermozilla-central@26bee50f8c27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1434710
milestone61.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 1434710 - Replaced all instances of mozilla::IndexSequence, mozilla::MakeIndexSequence and mozilla::IndexSequenceFor with std::index_sequence, std::make_index_sequence and std::index_sequence_for and removed mfbt/IndexSequence.h. r=botond MozReview-Commit-ID: 1Ema7TUNr5v
accessible/base/NotificationController.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaEventSource.h
dom/plugins/ipc/FunctionBroker.h
ipc/chromium/src/base/task.h
js/src/frontend/EitherParser.h
js/src/threading/Thread.h
media/mtransport/runnable_utils.h
mfbt/IndexSequence.h
mfbt/moz.build
widget/android/jni/Natives.h
xpcom/string/nsASCIIMask.h
xpcom/threads/MozPromise.h
xpcom/threads/nsThreadUtils.h
--- a/accessible/base/NotificationController.h
+++ b/accessible/base/NotificationController.h
@@ -4,21 +4,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_a11y_NotificationController_h_
 #define mozilla_a11y_NotificationController_h_
 
 #include "EventQueue.h"
 #include "EventTree.h"
 
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Tuple.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsRefreshDriver.h"
 
+#include <utility>
+
 #ifdef A11Y_LOG
 #include "Logging.h"
 #endif
 
 namespace mozilla {
 namespace a11y {
 
 class DocAccessible;
@@ -63,24 +64,24 @@ class TNotification : public Notificatio
 public:
   typedef void (Class::*Callback)(Args* ...);
 
   TNotification(Class* aInstance, Callback aCallback, Args* ... aArgs) :
     mInstance(aInstance), mCallback(aCallback), mArgs(aArgs...) { }
   virtual ~TNotification() { mInstance = nullptr; }
 
   virtual void Process() override
-    { ProcessHelper(typename IndexSequenceFor<Args...>::Type()); }
+    { ProcessHelper(std::index_sequence_for<Args...>{}); }
 
 private:
   TNotification(const TNotification&);
   TNotification& operator = (const TNotification&);
 
   template <size_t... Indices>
-    void ProcessHelper(IndexSequence<Indices...>)
+    void ProcessHelper(std::index_sequence<Indices...>)
   {
      (mInstance->*mCallback)(Get<Indices>(mArgs)...);
   }
 
   Class* mInstance;
   Callback mCallback;
   Tuple<RefPtr<Args> ...> mArgs;
 };
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1,23 +1,23 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include <algorithm>
 #include <stdint.h>
+#include <utility>
 
 #include "mediasink/AudioSink.h"
 #include "mediasink/AudioSinkWrapper.h"
 #include "mediasink/DecodedStream.h"
 #include "mediasink/OutputStreamManager.h"
 #include "mediasink/VideoSink.h"
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Logging.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/SharedThreadPool.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TaskQueue.h"
 #include "mozilla/Tuple.h"
@@ -252,17 +252,17 @@ protected:
   const MediaInfo& Info() const { return mMaster->Info(); }
   MediaQueue<AudioData>& AudioQueue() const { return mMaster->mAudioQueue; }
   MediaQueue<VideoData>& VideoQueue() const { return mMaster->mVideoQueue; }
 
   template <class S, typename... Args, size_t... Indexes>
   auto
   CallEnterMemberFunction(S* aS,
                           Tuple<Args...>& aTuple,
-                          IndexSequence<Indexes...>)
+                          std::index_sequence<Indexes...>)
     -> decltype(ReturnTypeHelper(&S::Enter))
   {
     return aS->Enter(Move(Get<Indexes>(aTuple))...);
   }
 
   // Note this function will delete the current state object.
   // Don't access members to avoid UAF after this call.
   template <class S, typename... Ts>
@@ -294,17 +294,17 @@ protected:
     master->OwnerThread()->DispatchDirectTask(
       NS_NewRunnableFunction("MDSM::StateObject::DeleteOldState",
                              [toDelete = Move(master->mStateObj)](){}));
     // Also reset mMaster to catch potentail UAF.
     mMaster = nullptr;
 
     master->mStateObj.reset(s);
     return CallEnterMemberFunction(s, copiedArgs,
-                                   typename IndexSequenceFor<Ts...>::Type());
+                                   std::index_sequence_for<Ts...>{});
   }
 
   RefPtr<MediaDecoder::SeekPromise>
   SetSeekingState(SeekJob&& aSeekJob, EventVisibility aVisibility);
 
   // Take a raw pointer in order not to change the life cycle of MDSM.
   // It is guaranteed to be valid by MDSM.
   Master* mMaster;
--- a/dom/media/MediaEventSource.h
+++ b/dom/media/MediaEventSource.h
@@ -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/. */
 
 #ifndef MediaEventSource_h_
 #define MediaEventSource_h_
 
 #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/Unused.h"
 
 #include "nsISupportsImpl.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
--- a/dom/plugins/ipc/FunctionBroker.h
+++ b/dom/plugins/ipc/FunctionBroker.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/. */
 
 #ifndef dom_plugins_ipc_PluginHooksWin_h
 #define dom_plugins_ipc_PluginHooksWin_h 1
 
 #include <map>
 #include <algorithm>
+#include <utility>
 #include "base/task.h"
 #include "mozilla/ipc/ProcessChild.h"
 #include "FunctionBrokerChild.h"
 #include "mtransport/runnable_utils.h"
 #include "PluginMessageUtils.h"
 #include "mozilla/Logging.h"
 #include "FunctionHook.h"
 #include "FunctionBrokerIPCUtils.h"
@@ -1258,17 +1259,17 @@ public:
     return BrokerCallServer(aClientId, aInTuple, aOutTuple);
   }
 
 protected:
   bool BrokerCallServer(base::ProcessId aClientId, const IpdlTuple &aInTuple,
                         IpdlTuple *aOutTuple) const
   {
     return BrokerCallServer(aClientId, aInTuple, aOutTuple,
-                             typename IndexSequenceFor<ParamTypes...>::Type());
+                             std::index_sequence_for<ParamTypes...>{});
   }
 
   bool BrokerCallClient(uint32_t& aWinError, ResultType& aResult, ParamTypes&... aParameters) const;
   bool PostToDispatchThread(uint32_t& aWinError, ResultType& aRet, ParamTypes&... aParameters) const;
 
   static void
   PostToDispatchHelper(const SelfType* bmhi, Monitor* monitor, bool* notified,
                        bool* ok, uint32_t* winErr, ResultType* r, ParamTypes*... p)
@@ -1298,17 +1299,17 @@ protected:
     return aFunction(aParams...);
   };
 
   bool BrokerCallServer(base::ProcessId aClientId, const IpdlTuple &aInTuple,
                         IpdlTuple *aOutTuple, ParamTypes&... aParams) const;
 
   template<size_t... Indices>
   bool BrokerCallServer(base::ProcessId aClientId, const IpdlTuple &aInTuple,
-                         IpdlTuple *aOutTuple, IndexSequence<Indices...>) const
+                         IpdlTuple *aOutTuple, std::index_sequence<Indices...>) const
   {
     TupleParamTypes paramTuple;
     return BrokerCallServer(aClientId, aInTuple, aOutTuple,
                              Get<Indices>(paramTuple)...);
   }
 };
 
 template <FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
--- a/ipc/chromium/src/base/task.h
+++ b/ipc/chromium/src/base/task.h
@@ -4,61 +4,60 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #ifndef BASE_TASK_H_
 #define BASE_TASK_H_
 
 #include "base/revocable_store.h"
 #include "base/tuple.h"
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Tuple.h"
 #include "nsISupportsImpl.h"
 #include "nsThreadUtils.h"
 
+#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
 // semantics from the given tuple. If the tuple has length N, the sequence must
 // be IndexSequence<0, 1, ..., N-1>.
 template<size_t... Indices, class ObjT, class Method, typename... Args>
-void CallMethod(mozilla::IndexSequence<Indices...>, ObjT* obj, Method method,
+void CallMethod(std::index_sequence<Indices...>, ObjT* obj, Method method,
                 mozilla::Tuple<Args...>& arg)
 {
   (obj->*method)(mozilla::Move(mozilla::Get<Indices>(arg))...);
 }
 
 // Same as above, but call a function.
 template<size_t... Indices, typename Function, typename... Args>
-void CallFunction(mozilla::IndexSequence<Indices...>, Function function,
+void CallFunction(std::index_sequence<Indices...>, Function function,
                   mozilla::Tuple<Args...>& arg)
 {
   (*function)(mozilla::Move(mozilla::Get<Indices>(arg))...);
 }
 
 } // namespace details
 
 // Call a method on the given object. Arguments are passed by move semantics
 // from the given tuple.
 template<class ObjT, class Method, typename... Args>
 void DispatchTupleToMethod(ObjT* obj, Method method, mozilla::Tuple<Args...>& arg)
 {
-  details::CallMethod(typename mozilla::IndexSequenceFor<Args...>::Type(),
-                      obj, method, arg);
+  details::CallMethod(std::index_sequence_for<Args...>{}, obj, method, arg);
 }
 
 // Same as above, but call a function.
 template<typename Function, typename... Args>
 void DispatchTupleToFunction(Function function, mozilla::Tuple<Args...>& arg)
 {
-  details::CallFunction(typename mozilla::IndexSequenceFor<Args...>::Type(),
-                        function, arg);
+  details::CallFunction(std::index_sequence_for<Args...>{}, function, arg);
 }
 
 // Scoped Factories ------------------------------------------------------------
 //
 // These scoped factory objects can be used by non-refcounted objects to safely
 // place tasks in a message loop.  Each factory guarantees that the tasks it
 // produces will not run after the factory is destroyed.  Commonly, factories
 // are declared as class members, so the class' tasks will automatically cancel
--- a/js/src/frontend/EitherParser.h
+++ b/js/src/frontend/EitherParser.h
@@ -8,58 +8,59 @@
  * A variant-like class abstracting operations on a Parser with a given ParseHandler but
  * unspecified character type.
  */
 
 #ifndef frontend_EitherParser_h
 #define frontend_EitherParser_h
 
 #include "mozilla/Attributes.h"
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Move.h"
 #include "mozilla/Tuple.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/Variant.h"
 
+#include <utility>
+
 #include "frontend/Parser.h"
 #include "frontend/TokenStream.h"
 
 namespace js {
 
 namespace detail {
 
 template<template <class Parser> class GetThis,
          template <class This> class MemberFunction,
          typename... Args>
 struct InvokeMemberFunction
 {
     mozilla::Tuple<typename mozilla::Decay<Args>::Type...> args;
 
     template<class This, size_t... Indices>
     auto
-    matchInternal(This* obj, mozilla::IndexSequence<Indices...>)
+    matchInternal(This* obj, std::index_sequence<Indices...>)
       -> decltype(((*obj).*(MemberFunction<This>::get()))(mozilla::Get<Indices>(args)...))
     {
         return ((*obj).*(MemberFunction<This>::get()))(mozilla::Get<Indices>(args)...);
     }
 
   public:
     template<typename... ActualArgs>
     explicit InvokeMemberFunction(ActualArgs&&... actualArgs)
       : args { mozilla::Forward<ActualArgs>(actualArgs)... }
     {}
 
     template<class Parser>
     auto
     match(Parser* parser)
       -> decltype(this->matchInternal(GetThis<Parser>::get(parser),
-                                      typename mozilla::IndexSequenceFor<Args...>::Type()))
+                                      std::index_sequence_for<Args...>{}))
     {
         return this->matchInternal(GetThis<Parser>::get(parser),
-                                   typename mozilla::IndexSequenceFor<Args...>::Type());
+                                   std::index_sequence_for<Args...>{});
     }
 };
 
 // |this|-computing templates.
 
 template<class Parser>
 struct GetParser
 {
--- a/js/src/threading/Thread.h
+++ b/js/src/threading/Thread.h
@@ -5,21 +5,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef threading_Thread_h
 #define threading_Thread_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 <utility>
 
 #include "jsutil.h"
 
 #include "threading/LockGuard.h"
 #include "threading/Mutex.h"
 #include "vm/MutexIDs.h"
 
 #ifdef XP_WIN
@@ -227,23 +227,23 @@ public:
   explicit ThreadTrampoline(G&& aG, ArgsT&&... aArgsT)
     : f(mozilla::Forward<F>(aG)),
       args(mozilla::Forward<Args>(aArgsT)...)
   {
   }
 
   static THREAD_RETURN_TYPE THREAD_CALL_API Start(void* aPack) {
     auto* pack = static_cast<ThreadTrampoline<F, Args...>*>(aPack);
-    pack->callMain(typename mozilla::IndexSequenceFor<Args...>::Type());
+    pack->callMain(std::index_sequence_for<Args...>{});
     js_delete(pack);
     return 0;
   }
 
   template<size_t ...Indices>
-  void callMain(mozilla::IndexSequence<Indices...>) {
+  void callMain(std::index_sequence<Indices...>) {
     f(mozilla::Get<Indices>(args)...);
   }
 };
 
 } // namespace detail
 } // namespace js
 
 #undef THREAD_RETURN_TYPE
--- a/media/mtransport/runnable_utils.h
+++ b/media/mtransport/runnable_utils.h
@@ -5,21 +5,22 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Original author: ekr@rtfm.com
 
 #ifndef runnable_utils_h__
 #define runnable_utils_h__
 
 #include "nsThreadUtils.h"
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Move.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Tuple.h"
 
+#include <utility>
+
 // Abstract base class for all of our templates
 namespace mozilla {
 
 namespace detail {
 
 enum RunnableResult {
   NoResult,
   ReturnsResult
@@ -39,53 +40,53 @@ class runnable_args_base : public Runnab
   NS_IMETHOD Run() override = 0;
 };
 
 
 template<typename R>
 struct RunnableFunctionCallHelper
 {
   template<typename FunType, typename... Args, size_t... Indices>
-  static R apply(FunType func, Tuple<Args...>& args, IndexSequence<Indices...>)
+  static R apply(FunType func, Tuple<Args...>& args, std::index_sequence<Indices...>)
   {
     return func(Get<Indices>(args)...);
   }
 };
 
 // A void specialization is needed in the case where the template instantiator
 // knows we don't want to return a value, but we don't know whether the called
 // function returns void or something else.
 template<>
 struct RunnableFunctionCallHelper<void>
 {
   template<typename FunType, typename... Args, size_t... Indices>
-  static void apply(FunType func, Tuple<Args...>& args, IndexSequence<Indices...>)
+  static void apply(FunType func, Tuple<Args...>& args, std::index_sequence<Indices...>)
   {
     func(Get<Indices>(args)...);
   }
 };
 
 template<typename R>
 struct RunnableMethodCallHelper
 {
   template<typename Class, typename M, typename... Args, size_t... Indices>
-  static R apply(Class obj, M method, Tuple<Args...>& args, IndexSequence<Indices...>)
+  static R apply(Class obj, M method, Tuple<Args...>& args, std::index_sequence<Indices...>)
   {
     return ((*obj).*method)(Get<Indices>(args)...);
   }
 };
 
 // A void specialization is needed in the case where the template instantiator
 // knows we don't want to return a value, but we don't know whether the called
 // method returns void or something else.
 template<>
 struct RunnableMethodCallHelper<void>
 {
   template<typename Class, typename M, typename... Args, size_t... Indices>
-  static void apply(Class obj, M method, Tuple<Args...>& args, IndexSequence<Indices...>)
+  static void apply(Class obj, M method, Tuple<Args...>& args, std::index_sequence<Indices...>)
   {
     ((*obj).*method)(Get<Indices>(args)...);
   }
 };
 
 }
 
 template<typename FunType, typename... Args>
@@ -94,17 +95,17 @@ class runnable_args_func : public detail
 public:
   // |explicit| to pacify static analysis when there are no |args|.
   template<typename... Arguments>
   explicit runnable_args_func(FunType f, Arguments&&... args)
     : mFunc(f), mArgs(Forward<Arguments>(args)...)
   {}
 
   NS_IMETHOD Run() override {
-    detail::RunnableFunctionCallHelper<void>::apply(mFunc, mArgs, typename IndexSequenceFor<Args...>::Type());
+    detail::RunnableFunctionCallHelper<void>::apply(mFunc, mArgs, std::index_sequence_for<Args...>{});
     return NS_OK;
   }
 
 private:
   FunType mFunc;
   Tuple<Args...> mArgs;
 };
 
@@ -120,17 +121,17 @@ class runnable_args_func_ret : public de
 {
 public:
   template<typename... Arguments>
   runnable_args_func_ret(Ret* ret, FunType f, Arguments&&... args)
     : mReturn(ret), mFunc(f), mArgs(Forward<Arguments>(args)...)
   {}
 
   NS_IMETHOD Run() override {
-    *mReturn = detail::RunnableFunctionCallHelper<Ret>::apply(mFunc, mArgs, typename IndexSequenceFor<Args...>::Type());
+    *mReturn = detail::RunnableFunctionCallHelper<Ret>::apply(mFunc, mArgs, std::index_sequence_for<Args...>{});
     return NS_OK;
   }
 
 private:
   Ret* mReturn;
   FunType mFunc;
   Tuple<Args...> mArgs;
 };
@@ -147,17 +148,17 @@ class runnable_args_memfn : public detai
 {
 public:
   template<typename... Arguments>
   runnable_args_memfn(Class obj, M method, Arguments&&... args)
     : mObj(obj), mMethod(method), mArgs(Forward<Arguments>(args)...)
   {}
 
   NS_IMETHOD Run() override {
-    detail::RunnableMethodCallHelper<void>::apply(mObj, mMethod, mArgs, typename IndexSequenceFor<Args...>::Type());
+    detail::RunnableMethodCallHelper<void>::apply(mObj, mMethod, mArgs, std::index_sequence_for<Args...>{});
     return NS_OK;
   }
 
 private:
   Class mObj;
   M mMethod;
   Tuple<Args...> mArgs;
 };
@@ -174,17 +175,17 @@ class runnable_args_memfn_ret : public d
 {
 public:
   template<typename... Arguments>
   runnable_args_memfn_ret(Ret* ret, Class obj, M method, Arguments... args)
     : mReturn(ret), mObj(obj), mMethod(method), mArgs(Forward<Arguments>(args)...)
   {}
 
   NS_IMETHOD Run() override {
-    *mReturn = detail::RunnableMethodCallHelper<Ret>::apply(mObj, mMethod, mArgs, typename IndexSequenceFor<Args...>::Type());
+    *mReturn = detail::RunnableMethodCallHelper<Ret>::apply(mObj, mMethod, mArgs, std::index_sequence_for<Args...>{});
     return NS_OK;
   }
 
 private:
   Ret* mReturn;
   Class mObj;
   M mMethod;
   Tuple<Args...> mArgs;
deleted file mode 100644
--- a/mfbt/IndexSequence.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-/* A utility for expanding a tuple into a variadic argument list.
- * Based on std::index_sequence. */
-
-/**
- * Example usage:
- *
- * Problem:
- *
- *   You have a variadic function Foo:
- *
- *     template <typename... Args> void Foo(Args...);
- *
- *   And a variadic function Bar, which contains a tuple:
- *
- *     template <typename... Args>
- *     void Bar() {
- *       // ...
- *       Tuple<Args...> t;
- *     }
- *
- *   And inside Bar, you want to call Foo with the elements of the tuple as
- *   arguments to Foo.
- *
- *   You want to write:
- *
- *     Foo(Get<0>(t), Get<1>(t), ..., Get<N>(t))
- *
- *   but you can't literally write that, because N is different for different
- *   instantiations of Bar.
- *
- * Solution:
- *
- *   Write a helper function which takes the tuple, and an index sequence
- *   containing indices corresponding to the tuple indices.
- *
- *     template <typename... Args, size_t... Indices>
- *     void Helper(const Tuple<Args...>& t, IndexSequence<Indices...>)
- *     {
- *       Foo(Get<Indices>(t)...);
- *     }
- *
- *   Assuming 'Indices...' are 0, 1, ..., N - 1, where N is the size of the
- *   tuple, pack expansion will expand the pack 'Get<Indices>(t)...' to
- *   'Get<0>(t), Get<1>(t), ..., Get<N>(t)'.
- *
- *   Finally, call the helper, creating the index sequence to pass in like so:
- *
- *     template <typename... Args>
- *     void Bar() {
- *       // ...
- *       Tuple<Args...> t;
- *       Helper(t, typename IndexSequenceFor<Args...>::Type());
- *     }
- */
-
-#ifndef mozilla_IndexSequence_h
-#define mozilla_IndexSequence_h
-
-#include "mozilla/Attributes.h"
-
-#include <stddef.h>
-
-namespace mozilla {
-
-/**
- * Represents a compile-time sequence of integer indices.
- */
-template<size_t... Indices>
-struct IndexSequence
-{
-  static constexpr size_t Size() { return sizeof...(Indices); }
-};
-
-namespace detail {
-
-// Helpers used by MakeIndexSequence.
-
-template<size_t... Indices>
-struct IndexTuple
-{
-  typedef IndexTuple<Indices..., sizeof...(Indices)> Next;
-};
-
-// Builds IndexTuple<0, 1, ..., N - 1>.
-template<size_t N>
-struct BuildIndexTuple
-{
-  typedef typename BuildIndexTuple<N - 1>::Type::Next Type;
-};
-
-template<>
-struct BuildIndexTuple<0>
-{
-  typedef IndexTuple<> Type;
-};
-
-template<size_t N, typename IndexTuple>
-struct MakeIndexSequenceImpl;
-
-template<size_t N, size_t... Indices>
-struct MakeIndexSequenceImpl<N, IndexTuple<Indices...>>
-{
-  typedef IndexSequence<Indices...> Type;
-};
-
-} // namespace detail
-
-/**
- * A utility for building an IndexSequence of consecutive indices.
- * MakeIndexSequence<N>::Type evaluates to IndexSequence<0, 1, .., N - 1>.
- * Note: unlike std::make_index_sequence, this is not an alias template
- * to work around bugs in MSVC 2013.
- */
-template<size_t N>
-struct MakeIndexSequence
-{
-  typedef typename detail::MakeIndexSequenceImpl<N,
-    typename detail::BuildIndexTuple<N>::Type>::Type Type;
-};
-
-/**
- * A utility for building an IndexSequence of consecutive indices
- * corresponding to a variadic argument list.
- * IndexSequenceFor<Types...> evaluates to IndexSequence<0, 1, ..., N - 1>
- * where N is the number of types in Types.
- * Note: unlike std::index_sequence_for, this is not an alias template
- * to work around bugs in MSVC 2013.
- */
-template<typename... Types>
-struct IndexSequenceFor
-{
-  typedef typename MakeIndexSequence<sizeof...(Types)>::Type Type;
-};
-
-} // namespace mozilla
-
-#endif /* mozilla_IndexSequence_h */
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -39,17 +39,16 @@ EXPORTS.mozilla = [
     'EnumeratedRange.h',
     'EnumSet.h',
     'EnumTypeTraits.h',
     'FastBernoulliTrial.h',
     'FloatingPoint.h',
     'FStream.h',
     'GuardObjects.h',
     'HashFunctions.h',
-    'IndexSequence.h',
     'IntegerPrintfMacros.h',
     'IntegerRange.h',
     'IntegerTypeTraits.h',
     'JSONWriter.h',
     'Likely.h',
     'LinkedList.h',
     'MacroArgs.h',
     'MacroForEach.h',
--- a/widget/android/jni/Natives.h
+++ b/widget/android/jni/Natives.h
@@ -1,16 +1,16 @@
 #ifndef mozilla_jni_Natives_h__
 #define mozilla_jni_Natives_h__
 
 #include <jni.h>
+#include <utility>
 
 #include "nsThreadUtils.h"
 
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Move.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Tuple.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/WeakPtr.h"
 #include "mozilla/Unused.h"
 #include "mozilla/jni/Accessors.h"
@@ -400,51 +400,51 @@ class ProxyNativeCall
 
     // We cannot use IsStatic and HasThisArg directly (without going through
     // extra hoops) because GCC complains about invalid overloads, so we use
     // another pair of template parameters, Static and ThisArg.
 
     template<bool Static, bool ThisArg, size_t... Indices>
     typename mozilla::EnableIf<Static && ThisArg, void>::Type
     Call(const Class::LocalRef& cls,
-         mozilla::IndexSequence<Indices...>) const
+         std::index_sequence<Indices...>) const
     {
         (*mNativeCall)(cls, mozilla::Get<Indices>(mArgs)...);
     }
 
     template<bool Static, bool ThisArg, size_t... Indices>
     typename mozilla::EnableIf<Static && !ThisArg, void>::Type
     Call(const Class::LocalRef& cls,
-         mozilla::IndexSequence<Indices...>) const
+         std::index_sequence<Indices...>) const
     {
         (*mNativeCall)(mozilla::Get<Indices>(mArgs)...);
     }
 
     template<bool Static, bool ThisArg, size_t... Indices>
     typename mozilla::EnableIf<!Static && ThisArg, void>::Type
     Call(const typename Owner::LocalRef& inst,
-         mozilla::IndexSequence<Indices...>) const
+         std::index_sequence<Indices...>) const
     {
         Impl* const impl = NativePtr<Impl>::Get(inst);
         MOZ_CATCH_JNI_EXCEPTION(inst.Env());
         (impl->*mNativeCall)(inst, mozilla::Get<Indices>(mArgs)...);
     }
 
     template<bool Static, bool ThisArg, size_t... Indices>
     typename mozilla::EnableIf<!Static && !ThisArg, void>::Type
     Call(const typename Owner::LocalRef& inst,
-         mozilla::IndexSequence<Indices...>) const
+         std::index_sequence<Indices...>) const
     {
         Impl* const impl = NativePtr<Impl>::Get(inst);
         MOZ_CATCH_JNI_EXCEPTION(inst.Env());
         (impl->*mNativeCall)(mozilla::Get<Indices>(mArgs)...);
     }
 
     template<size_t... Indices>
-    void Clear(JNIEnv* env, mozilla::IndexSequence<Indices...>)
+    void Clear(JNIEnv* env, std::index_sequence<Indices...>)
     {
         int dummy[] = {
             (ProxyArg<Args>::Clear(env, Get<Indices>(mArgs)), 0)...
         };
         mozilla::Unused << dummy;
     }
 
     static Impl* GetNativeObject(Class::Param thisArg) { return nullptr; }
@@ -492,23 +492,23 @@ public:
     void SetTarget(NativeCallType call) { mNativeCall = call; }
     template<typename T> void SetTarget(T&&) const { MOZ_CRASH(); }
 
     void operator()()
     {
         JNIEnv* const env = GetEnvForThread();
         typename ThisArgClass::LocalRef thisArg(env, mThisArg);
         Call<IsStatic, HasThisArg>(
-                thisArg, typename IndexSequenceFor<Args...>::Type());
+                thisArg, std::index_sequence_for<Args...>{});
 
         // Clear all saved global refs. We do this after the call is invoked,
         // and not inside the destructor because we already have a JNIEnv here,
         // so it's more efficient to clear out the saved args here. The
         // downside is that the call can only be invoked once.
-        Clear(env, typename IndexSequenceFor<Args...>::Type());
+        Clear(env, std::index_sequence_for<Args...>{});
         mThisArg.Clear(env);
     }
 };
 
 template<class Impl, bool HasThisArg, typename... Args>
 struct Dispatcher
 {
     template<class Traits, bool IsStatic = Traits::isStatic,
--- a/xpcom/string/nsASCIIMask.h
+++ b/xpcom/string/nsASCIIMask.h
@@ -3,17 +3,19 @@
 /* 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 nsASCIIMask_h_
 #define nsASCIIMask_h_
 
 #include <array>
-#include "mozilla/IndexSequence.h"
+#include <utility>
+
+#include "mozilla/Attributes.h"
 
 typedef std::array<bool, 128> ASCIIMaskArray;
 
 namespace mozilla {
 
 // Boolean arrays, fixed size and filled in at compile time, meant to
 // record something about each of the (standard) ASCII characters.
 // No extended ASCII for now, there has been no use case.
@@ -49,23 +51,23 @@ public:
 // constexpr std::array<bool, 128> sABCMask = CreateASCIIMask(TestABC);
 // ...
 // if (someChar < 128 && sABCMask[someChar]) this is A or B or C
 
 
 namespace details
 {
 template<typename F, size_t... Indices>
-constexpr std::array<bool, 128> CreateASCIIMask(F fun, mozilla::IndexSequence<Indices...>)
+constexpr std::array<bool, 128> CreateASCIIMask(F fun, std::index_sequence<Indices...>)
 {
   return {{ fun(Indices)... }};
 }
 } // namespace details
 
 template<typename F>
 constexpr std::array<bool, 128> CreateASCIIMask(F fun)
 {
-  return details::CreateASCIIMask(fun, mozilla::MakeIndexSequence<128>::Type{});
+  return details::CreateASCIIMask(fun, std::make_index_sequence<128>{});
 }
 
 } // namespace mozilla
 
 #endif // nsASCIIMask_h_
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -2,17 +2,16 @@
 /* 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/. */
 
 #if !defined(MozPromise_h_)
 #define MozPromise_h_
 
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Tuple.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/Variant.h"
--- a/xpcom/threads/nsThreadUtils.h
+++ b/xpcom/threads/nsThreadUtils.h
@@ -17,23 +17,24 @@
 #include "nsIRunnable.h"
 #include "nsIThreadManager.h"
 #include "nsITimer.h"
 #include "nsIThread.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Atomics.h"
-#include "mozilla/IndexSequence.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Move.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Tuple.h"
 #include "mozilla/TypeTraits.h"
 
+#include <utility>
+
 //-----------------------------------------------------------------------------
 // These methods are alternatives to the methods on nsIThreadManager, provided
 // for convenience.
 
 /**
  * Create a new thread, and optionally provide an initial event for the thread.
  *
  * @param aResult
@@ -1153,27 +1154,27 @@ struct RunnableMethodArguments final
 {
   Tuple<typename ::detail::ParameterStorage<Ts>::Type...> mArguments;
   template <typename... As>
   explicit RunnableMethodArguments(As&&... aArguments)
     : mArguments(Forward<As>(aArguments)...)
   {}
   template<typename C, typename M, typename... Args, size_t... Indices>
   static auto
-  applyImpl(C* o, M m, Tuple<Args...>& args, IndexSequence<Indices...>)
+  applyImpl(C* o, M m, Tuple<Args...>& args, std::index_sequence<Indices...>)
       -> decltype(((*o).*m)(Get<Indices>(args).PassAsParameter()...))
   {
     return ((*o).*m)(Get<Indices>(args).PassAsParameter()...);
   }
   template<class C, typename M> auto apply(C* o, M m)
       -> decltype(applyImpl(o, m, mArguments,
-                  typename IndexSequenceFor<Ts...>::Type()))
+                  std::index_sequence_for<Ts...>{}))
   {
     return applyImpl(o, m, mArguments,
-        typename IndexSequenceFor<Ts...>::Type());
+        std::index_sequence_for<Ts...>{});
   }
 };
 
 template<typename PtrType, typename Method, bool Owning, RunnableKind Kind, typename... Storages>
 class RunnableMethodImpl final
   : public ::nsRunnableMethodTraits<PtrType, Method, Owning, Kind>::base_type
 {
   typedef typename ::nsRunnableMethodTraits<PtrType, Method, Owning, Kind> Traits;