28 #ifndef VC_COMMON_INDEXSEQUENCE_H_
29 #define VC_COMMON_INDEXSEQUENCE_H_
31 #include <Vc/global.h>
33 namespace Vc_VERSIONED_NAMESPACE
39 template <std::size_t... I>
struct index_sequence
41 static constexpr std::size_t size() noexcept {
return sizeof...(I); }
48 template <std::
size_t N>
struct make_index_sequence_impl {
49 template <std::size_t Offset, std::size_t... Ns>
50 static index_sequence<Ns..., (Ns + Offset)...> join(std::false_type,
51 index_sequence<Ns...>);
52 template <std::size_t Offset, std::size_t... Ns>
53 static index_sequence<Ns..., Offset - 1, (Ns + Offset)...> join(
54 std::true_type, index_sequence<Ns...>);
56 using is_odd = std::integral_constant<bool, N & 1>;
57 using half =
typename make_index_sequence_impl<N / 2>::type;
58 using type = decltype(join<(N + 1) / 2>(is_odd(), half()));
60 template <>
struct make_index_sequence_impl<0> {
61 using type = index_sequence<>;
63 template <>
struct make_index_sequence_impl<1> {
64 using type = index_sequence<0>;
66 template <>
struct make_index_sequence_impl<2> {
67 using type = index_sequence<0, 1>;
73 template <std::
size_t N>
74 using make_index_sequence =
typename make_index_sequence_impl<N>::type;
77 #endif // VC_COMMON_INDEXSEQUENCE_H_