ALPSCore reference
index_sequence.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 
7 #ifndef ALPSCORE_INDEX_SEQUENCE_HPP
8 #define ALPSCORE_INDEX_SEQUENCE_HPP
9 
10 #include <type_traits>
11 
12 namespace alps{
15  template<typename T, T... I>
18  using value_type = T;
20  static constexpr std::size_t size() noexcept {
21  return sizeof...(I);
22  }
23  };
24 
25  namespace integer_sequence_detail {
26  template <typename, typename> struct concat;
27 
28  template <typename T, T... A, T... B>
29  struct concat<integer_sequence<T, A...>, integer_sequence<T, B...>> {
30  typedef integer_sequence<T, A..., B...> type;
31  };
32 
33  template <typename T, size_t First, size_t Count>
34  struct build_helper {
35  using type = typename concat<
36  typename build_helper<T, First, Count/2>::type,
37  typename build_helper<T, First + Count/2, Count - Count/2>::type
39  };
40 
41  template <typename T, size_t First>
42  struct build_helper<T, First, 1> {
44  };
45 
46  template <typename T, size_t First>
47  struct build_helper<T, First, 0> {
49  };
50 
51  template <typename T, T N>
53  } // namespace integer_sequence_detail
54 
55  template <typename T, T N>
57 
58  template <std::size_t... I>
59  using index_sequence = integer_sequence<std::size_t, I...>;
60 
61  template<size_t N>
63 
64 
65 }
66 
67 #endif //ALPSCORE_INDEX_SEQUENCE_HPP
make_integer_sequence< size_t, N > make_index_sequence
typename build_helper< T, 0, N >::type builder
static constexpr std::size_t size() noexcept
size of sequence
integer_sequence_detail::builder< T, N > make_integer_sequence
typename concat< typename build_helper< T, First, Count/2 >::type, typename build_helper< T, First+Count/2, Count-Count/2 >::type >::type type
T value_type
type of sequence