Back to home page

EIC code displayed by LXR

 
 

    


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 // Copyright 2015, 2017, 2019 Peter Dimov.
0005 //
0006 // Distributed under the Boost Software License, Version 1.0.
0007 //
0008 // See accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt
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 // integer_sequence
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 // detail::make_integer_sequence_impl
0036 namespace detail
0037 {
0038 
0039 // iseq_if_c
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 // iseq_identity
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 } // namespace detail
0093 
0094 // make_integer_sequence
0095 template<class T, T N> using make_integer_sequence = typename detail::make_integer_sequence_impl<T, N>::type;
0096 
0097 #endif // defined(BOOST_BIND_DETAIL_HAS_MAKE_INTEGER_SEQ)
0098 
0099 // index_sequence
0100 template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;
0101 
0102 // make_index_sequence
0103 template<std::size_t N> using make_index_sequence = make_integer_sequence<std::size_t, N>;
0104 
0105 // index_sequence_for
0106 template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
0107 
0108 } // namespace _bi
0109 } // namespace boost
0110 
0111 #endif // #ifndef BOOST_BIND_DETAIL_INTEGER_SEQUENCE_HPP_INCLUDED