| 1 |
//===----------------------------------------------------------------------===// |
| 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 _LIBCPP___CXX03___UTILITY_INTEGER_SEQUENCE_H |
| 10 |
#define _LIBCPP___CXX03___UTILITY_INTEGER_SEQUENCE_H |
| 11 |
|
| 12 |
#include <__cxx03/__config> |
| 13 |
#include <__cxx03/__type_traits/is_integral.h> |
| 14 |
#include <__cxx03/cstddef> |
| 15 |
|
| 16 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 |
# pragma GCC system_header |
| 18 |
#endif |
| 19 |
|
| 20 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 21 |
|
| 22 |
template <size_t...> |
| 23 |
struct __tuple_indices; |
| 24 |
|
| 25 |
template <class _IdxType, _IdxType... _Values> |
| 26 |
struct __integer_sequence { |
| 27 |
template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType> |
| 28 |
using __convert = _ToIndexSeq<_ToIndexType, _Values...>; |
| 29 |
|
| 30 |
template <size_t _Sp> |
| 31 |
using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>; |
| 32 |
}; |
| 33 |
|
| 34 |
#if __has_builtin(__make_integer_seq) |
| 35 |
template <size_t _Ep, size_t _Sp> |
| 36 |
using __make_indices_imp = |
| 37 |
typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>; |
| 38 |
#elif __has_builtin(__integer_pack) |
| 39 |
template <size_t _Ep, size_t _Sp> |
| 40 |
using __make_indices_imp = |
| 41 |
typename __integer_sequence<size_t, __integer_pack(_Ep - _Sp)...>::template __to_tuple_indices<_Sp>; |
| 42 |
#else |
| 43 |
# error "No known way to get an integer pack from the compiler" |
| 44 |
#endif |
| 45 |
|
| 46 |
_LIBCPP_END_NAMESPACE_STD |
| 47 |
|
| 48 |
#endif // _LIBCPP___CXX03___UTILITY_INTEGER_SEQUENCE_H |