Blame view

3rdparty/boost_1_81_0/boost/mp11/integer_sequence.hpp 2.85 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  #ifndef BOOST_MP11_INTEGER_SEQUENCE_HPP_INCLUDED
  #define BOOST_MP11_INTEGER_SEQUENCE_HPP_INCLUDED
  
  // Copyright 2015, 2017, 2019 Peter Dimov.
  //
  // Distributed under the Boost Software License, Version 1.0.
  //
  // See accompanying file LICENSE_1_0.txt or copy at
  // http://www.boost.org/LICENSE_1_0.txt
  
  #include <boost/mp11/version.hpp>
  #include <cstddef>
  
  #if defined(__has_builtin)
  # if __has_builtin(__make_integer_seq)
  #  define BOOST_MP11_HAS_MAKE_INTEGER_SEQ
  # endif
  #endif
  
  namespace boost
  {
  namespace mp11
  {
  
  // integer_sequence
  template<class T, T... I> struct integer_sequence
  {
  };
  
  #if defined(BOOST_MP11_HAS_MAKE_INTEGER_SEQ)
  
  template<class T, T N> using make_integer_sequence = __make_integer_seq<integer_sequence, T, N>;
  
  #else
  
  // detail::make_integer_sequence_impl
  namespace detail
  {
  
  // iseq_if_c
  template<bool C, class T, class E> struct iseq_if_c_impl;
  
  template<class T, class E> struct iseq_if_c_impl<true, T, E>
  {
      using type = T;
  };
  
  template<class T, class E> struct iseq_if_c_impl<false, T, E>
  {
      using type = E;
  };
  
  template<bool C, class T, class E> using iseq_if_c = typename iseq_if_c_impl<C, T, E>::type;
  
  // iseq_identity
  template<class T> struct iseq_identity
  {
      using type = T;
  };
  
  template<class S1, class S2> struct append_integer_sequence;
  
  template<class T, T... I, T... J> struct append_integer_sequence<integer_sequence<T, I...>, integer_sequence<T, J...>>
  {
      using type = integer_sequence< T, I..., ( J + sizeof...(I) )... >;
  };
  
  template<class T, T N> struct make_integer_sequence_impl;
  
  template<class T, T N> struct make_integer_sequence_impl_
  {
  private:
  
      static_assert( N >= 0, "make_integer_sequence<T, N>: N must not be negative" );
  
      static T const M = N / 2;
      static T const R = N % 2;
  
      using S1 = typename make_integer_sequence_impl<T, M>::type;
      using S2 = typename append_integer_sequence<S1, S1>::type;
      using S3 = typename make_integer_sequence_impl<T, R>::type;
      using S4 = typename append_integer_sequence<S2, S3>::type;
  
  public:
  
      using type = S4;
  };
  
  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> > >
  {
  };
  
  } // namespace detail
  
  // make_integer_sequence
  template<class T, T N> using make_integer_sequence = typename detail::make_integer_sequence_impl<T, N>::type;
  
  #endif // defined(BOOST_MP11_HAS_MAKE_INTEGER_SEQ)
  
  // index_sequence
  template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;
  
  // make_index_sequence
  template<std::size_t N> using make_index_sequence = make_integer_sequence<std::size_t, N>;
  
  // index_sequence_for
  template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
  
  } // namespace mp11
  } // namespace boost
  
  #endif // #ifndef BOOST_MP11_INTEGER_SEQUENCE_HPP_INCLUDED