File indexing completed on 2025-12-13 09:41:34
0001 #ifndef BOOST_BIND_DETAIL_INTEGER_SEQUENCE_HPP_INCLUDED
0002 #define BOOST_BIND_DETAIL_INTEGER_SEQUENCE_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <cstddef>
0012
0013 #if defined(__has_builtin)
0014 # if __has_builtin(__make_integer_seq)
0015 # define BOOST_BIND_DETAIL_HAS_MAKE_INTEGER_SEQ
0016 # endif
0017 #endif
0018
0019 namespace boost
0020 {
0021 namespace _bi
0022 {
0023
0024
0025 template<class T, T... I> struct integer_sequence
0026 {
0027 };
0028
0029 #if defined(BOOST_BIND_DETAIL_HAS_MAKE_INTEGER_SEQ)
0030
0031 template<class T, T N> using make_integer_sequence = __make_integer_seq<integer_sequence, T, N>;
0032
0033 #else
0034
0035
0036 namespace detail
0037 {
0038
0039
0040 template<bool C, class T, class E> struct iseq_if_c_impl;
0041
0042 template<class T, class E> struct iseq_if_c_impl<true, T, E>
0043 {
0044 using type = T;
0045 };
0046
0047 template<class T, class E> struct iseq_if_c_impl<false, T, E>
0048 {
0049 using type = E;
0050 };
0051
0052 template<bool C, class T, class E> using iseq_if_c = typename iseq_if_c_impl<C, T, E>::type;
0053
0054
0055 template<class T> struct iseq_identity
0056 {
0057 using type = T;
0058 };
0059
0060 template<class S1, class S2> struct append_integer_sequence;
0061
0062 template<class T, T... I, T... J> struct append_integer_sequence<integer_sequence<T, I...>, integer_sequence<T, J...>>
0063 {
0064 using type = integer_sequence< T, I..., ( J + sizeof...(I) )... >;
0065 };
0066
0067 template<class T, T N> struct make_integer_sequence_impl;
0068
0069 template<class T, T N> struct make_integer_sequence_impl_
0070 {
0071 private:
0072
0073 static_assert( N >= 0, "make_integer_sequence<T, N>: N must not be negative" );
0074
0075 static T const M = N / 2;
0076 static T const R = N % 2;
0077
0078 using S1 = typename make_integer_sequence_impl<T, M>::type;
0079 using S2 = typename append_integer_sequence<S1, S1>::type;
0080 using S3 = typename make_integer_sequence_impl<T, R>::type;
0081 using S4 = typename append_integer_sequence<S2, S3>::type;
0082
0083 public:
0084
0085 using type = S4;
0086 };
0087
0088 template<class T, T N> struct make_integer_sequence_impl: iseq_if_c<N == 0, iseq_identity<integer_sequence<T>>, iseq_if_c<N == 1, iseq_identity<integer_sequence<T, 0>>, make_integer_sequence_impl_<T, N> > >
0089 {
0090 };
0091
0092 }
0093
0094
0095 template<class T, T N> using make_integer_sequence = typename detail::make_integer_sequence_impl<T, N>::type;
0096
0097 #endif
0098
0099
0100 template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;
0101
0102
0103 template<std::size_t N> using make_index_sequence = make_integer_sequence<std::size_t, N>;
0104
0105
0106 template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
0107
0108 }
0109 }
0110
0111 #endif