1 //===-- Analogous to <utility> ----------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H 10 #define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H 11 12 #include "src/__support/CPP/TypeTraits.h" 13 14 namespace __llvm_libc::cpp { 15 16 template <typename T, T... Seq> struct IntegerSequence { 17 static_assert(IsIntegral<T>::Value); 18 template <T Next> using append = IntegerSequence<T, Seq..., Next>; 19 }; 20 21 namespace internal { 22 23 template <typename T, int N> struct MakeIntegerSequence { 24 using type = typename MakeIntegerSequence<T, N - 1>::type::template append<N>; 25 }; 26 27 template <typename T> struct MakeIntegerSequence<T, -1> { 28 using type = IntegerSequence<T>; 29 }; 30 31 } // namespace internal 32 33 template <typename T, int N> 34 using MakeIntegerSequence = 35 typename internal::MakeIntegerSequence<T, N - 1>::type; 36 37 } // namespace __llvm_libc::cpp 38 39 #endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H 40