Format: Modernize using variadic templates.
[oota-llvm.git] / include / llvm / ADT / STLExtras.h
index 804bdae0c7c83a40687ef3e1ff64c479b3a7d880..265cffd4c19857dd91d94ddf58c8a8a53176c67d 100644 (file)
@@ -194,6 +194,28 @@ struct less_second {
   }
 };
 
+// A subset of N3658. More stuff can be added as-needed.
+
+/// \brief Represents a compile-time sequence of integers.
+template <class T, T... I> struct integer_sequence {
+  typedef T value_type;
+
+  static LLVM_CONSTEXPR size_t size() { return sizeof...(I); }
+};
+
+template <std::size_t N, std::size_t... I>
+struct build_index_impl : build_index_impl<N - 1, N - 1, I...> {};
+template <std::size_t... I>
+struct build_index_impl<0, I...> : integer_sequence<std::size_t, I...> {};
+
+/// \brief Alias for the common case of a sequence of size_ts.
+template <size_t... I>
+using index_sequence = integer_sequence<std::size_t, I...>;
+
+/// \brief Creates a compile-time integer sequence for a parameter pack.
+template <class... Ts>
+using index_sequence_for = build_index_impl<sizeof...(Ts)>;
+
 //===----------------------------------------------------------------------===//
 //     Extra additions for arrays
 //===----------------------------------------------------------------------===//