-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtuple.hpp
More file actions
34 lines (28 loc) · 703 Bytes
/
tuple.hpp
File metadata and controls
34 lines (28 loc) · 703 Bytes
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
//tuple.hpp
namespace MySpace
{
template<int N, class... Ts>
struct tuple_data;
template<int N>
struct tuple_data<N>{};
template<int N, class Thead, class... Tbody>
struct tuple_data<N, Thead, Tbody...> : public tuple_data<N + 1, Tbody...>
{
Thead value;
};
template<int N, class... Ts>
auto& get_tuple_data(tuple_data<N, Ts...>& _t) //C++11なら->decltype(get_tuple_data<N>(_t))
{
return _t.value;
}
template<class... Ts>
struct tuple : tuple_data<0, Ts...>
{
static constexpr std::size_t size(void){return sizeof...(Ts);}
};
template<int N, class... Ts>
auto& get(tuple<Ts...>& _t) //C++11なら->decltype(get_tuple_data<N>(_t))
{
return get_tuple_data<N>(_t);
}
}