/
void_tuple.hpp
47 lines (36 loc) · 1.1 KB
/
void_tuple.hpp
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
#ifndef LFL_VOID_TUPLE_HPP
#define LFL_VOID_TUPLE_HPP
#include <cstddef>
namespace lfl {
using index_t = std::ptrdiff_t;
// void_tuple
template<class... Voids>
struct void_tuple { };
namespace {
// void_tuple_build
template<class VoidTuple, lfl::index_t Step, bool Even>
struct void_tuple_build;
template<class... Voids, lfl::index_t Step>
struct void_tuple_build<lfl::void_tuple<Voids...>, Step, true>
{
using type = lfl::void_tuple<Voids..., Voids...>;
};
template<class... Voids, lfl::index_t Step>
struct void_tuple_build<lfl::void_tuple<Voids...>, Step, false>
{
using type = lfl::void_tuple<Voids..., Voids..., void>;
};
// void_tuple_impl
template<std::size_t N>
struct void_tuple_impl : public lfl::void_tuple_build<typename lfl::void_tuple_impl<N/2>::type, N/2, N%2 == 0> { };
template<>
struct void_tuple_impl<0>
{
using type = lfl::void_tuple<>;
};
} // detail
// make_void_tuple
template<std::size_t N>
using make_void_tuple = typename lfl::void_tuple_impl<N>::type;
} // lfl
#endif // LFL_VOID_TUPLE_HPP