1//===-- integer_sequence 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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
10
11#include "src/__support/CPP/type_traits/is_integral.h"
12
13namespace LIBC_NAMESPACE::cpp {
14
15// integer_sequence
16template <typename T, T... Ints> struct integer_sequence {
17 static_assert(cpp::is_integral_v<T>);
18 template <T Next> using append = integer_sequence<T, Ints..., Next>;
19};
20
21namespace detail {
22template <typename T, int N> struct make_integer_sequence {
23 using type =
24 typename make_integer_sequence<T, N - 1>::type::template append<N>;
25};
26template <typename T> struct make_integer_sequence<T, -1> {
27 using type = integer_sequence<T>;
28};
29} // namespace detail
30
31template <typename T, int N>
32using make_integer_sequence =
33 typename detail::make_integer_sequence<T, N - 1>::type;
34
35} // namespace LIBC_NAMESPACE::cpp
36
37#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
38

source code of libc/src/__support/CPP/utility/integer_sequence.h