Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:45

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___UTILITY_INTEGER_SEQUENCE_H
0010 #define _LIBCPP___CXX03___UTILITY_INTEGER_SEQUENCE_H
0011 
0012 #include <__cxx03/__config>
0013 #include <__cxx03/__type_traits/is_integral.h>
0014 #include <__cxx03/cstddef>
0015 
0016 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0017 #  pragma GCC system_header
0018 #endif
0019 
0020 _LIBCPP_BEGIN_NAMESPACE_STD
0021 
0022 template <size_t...>
0023 struct __tuple_indices;
0024 
0025 template <class _IdxType, _IdxType... _Values>
0026 struct __integer_sequence {
0027   template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
0028   using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
0029 
0030   template <size_t _Sp>
0031   using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
0032 };
0033 
0034 #if __has_builtin(__make_integer_seq)
0035 template <size_t _Ep, size_t _Sp>
0036 using __make_indices_imp =
0037     typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>;
0038 #elif __has_builtin(__integer_pack)
0039 template <size_t _Ep, size_t _Sp>
0040 using __make_indices_imp =
0041     typename __integer_sequence<size_t, __integer_pack(_Ep - _Sp)...>::template __to_tuple_indices<_Sp>;
0042 #else
0043 #  error "No known way to get an integer pack from the compiler"
0044 #endif
0045 
0046 #if _LIBCPP_STD_VER >= 14
0047 
0048 template <class _Tp, _Tp... _Ip>
0049 struct _LIBCPP_TEMPLATE_VIS integer_sequence {
0050   typedef _Tp value_type;
0051   static_assert(is_integral<_Tp>::value, "std::integer_sequence can only be instantiated with an integral type");
0052   static _LIBCPP_HIDE_FROM_ABI constexpr size_t size() noexcept { return sizeof...(_Ip); }
0053 };
0054 
0055 template <size_t... _Ip>
0056 using index_sequence = integer_sequence<size_t, _Ip...>;
0057 
0058 #  if __has_builtin(__make_integer_seq)
0059 
0060 template <class _Tp, _Tp _Ep>
0061 using make_integer_sequence _LIBCPP_NODEBUG = __make_integer_seq<integer_sequence, _Tp, _Ep>;
0062 
0063 #  elif __has_builtin(__integer_pack)
0064 
0065 template <class _Tp, _Tp _SequenceSize>
0066 using make_integer_sequence _LIBCPP_NODEBUG = integer_sequence<_Tp, __integer_pack(_SequenceSize)...>;
0067 
0068 #  else
0069 #    error "No known way to get an integer pack from the compiler"
0070 #  endif
0071 
0072 template <size_t _Np>
0073 using make_index_sequence = make_integer_sequence<size_t, _Np>;
0074 
0075 template <class... _Tp>
0076 using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
0077 
0078 #  if _LIBCPP_STD_VER >= 20
0079 // Executes __func for every element in an index_sequence.
0080 template <size_t... _Index, class _Function>
0081 _LIBCPP_HIDE_FROM_ABI constexpr void __for_each_index_sequence(index_sequence<_Index...>, _Function __func) {
0082   (__func.template operator()<_Index>(), ...);
0083 }
0084 #  endif // _LIBCPP_STD_VER >= 20
0085 
0086 #endif // _LIBCPP_STD_VER >= 14
0087 
0088 _LIBCPP_END_NAMESPACE_STD
0089 
0090 #endif // _LIBCPP___CXX03___UTILITY_INTEGER_SEQUENCE_H