14acc3ffbSGuillaume Chatelet //===-- integer_sequence utility --------------------------------*- C++ -*-===// 24acc3ffbSGuillaume Chatelet // 34acc3ffbSGuillaume Chatelet // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 44acc3ffbSGuillaume Chatelet // See https://llvm.org/LICENSE.txt for license information. 54acc3ffbSGuillaume Chatelet // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 64acc3ffbSGuillaume Chatelet // 74acc3ffbSGuillaume Chatelet //===----------------------------------------------------------------------===// 8270547f3SGuillaume Chatelet #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H 9270547f3SGuillaume Chatelet #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H 104acc3ffbSGuillaume Chatelet 114acc3ffbSGuillaume Chatelet #include "src/__support/CPP/type_traits/is_integral.h" 12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 134acc3ffbSGuillaume Chatelet 14*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 15*5ff3ff33SPetr Hosek namespace cpp { 164acc3ffbSGuillaume Chatelet 174acc3ffbSGuillaume Chatelet // integer_sequence 184acc3ffbSGuillaume Chatelet template <typename T, T... Ints> struct integer_sequence { 194acc3ffbSGuillaume Chatelet static_assert(cpp::is_integral_v<T>); 204acc3ffbSGuillaume Chatelet template <T Next> using append = integer_sequence<T, Ints..., Next>; 214acc3ffbSGuillaume Chatelet }; 224acc3ffbSGuillaume Chatelet 234acc3ffbSGuillaume Chatelet namespace detail { 244acc3ffbSGuillaume Chatelet template <typename T, int N> struct make_integer_sequence { 254acc3ffbSGuillaume Chatelet using type = 264acc3ffbSGuillaume Chatelet typename make_integer_sequence<T, N - 1>::type::template append<N>; 274acc3ffbSGuillaume Chatelet }; 284acc3ffbSGuillaume Chatelet template <typename T> struct make_integer_sequence<T, -1> { 294acc3ffbSGuillaume Chatelet using type = integer_sequence<T>; 304acc3ffbSGuillaume Chatelet }; 314acc3ffbSGuillaume Chatelet } // namespace detail 324acc3ffbSGuillaume Chatelet 334acc3ffbSGuillaume Chatelet template <typename T, int N> 344acc3ffbSGuillaume Chatelet using make_integer_sequence = 354acc3ffbSGuillaume Chatelet typename detail::make_integer_sequence<T, N - 1>::type; 364acc3ffbSGuillaume Chatelet 37*5ff3ff33SPetr Hosek } // namespace cpp 38*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 394acc3ffbSGuillaume Chatelet 40270547f3SGuillaume Chatelet #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H 41