1 | #include <tuple>
|
2 | #include <vector>
|
3 | #include <type_traits>
|
4 |
|
5 | template<typename... Types>
|
6 | using get_first = typename std::tuple_element<0,std::tuple<Types...>>::type;
|
7 |
|
8 | template <typename T>
|
9 | struct skip_first{};
|
10 |
|
11 | template <typename First, typename... Rest>
|
12 | struct skip_first<std::tuple<First, Rest...>>
|
13 | {
|
14 | using type = std::tuple<Rest...>;
|
15 | };
|
16 |
|
17 | template <typename Container, typename FirstType, typename... RestTypes>
|
18 | struct Sub
|
19 | {
|
20 | const Container m_c;
|
21 | Sub(const Container& c):m_c(c){}
|
22 | using first_type = FirstType;
|
23 |
|
24 | using sub_first_type = get_first<RestTypes...>;
|
25 | using sub = Sub<Container, sub_first_type, RestTypes.../*[1...]*/>;
|
26 | sub get_sub() { return Sub(m_c); }
|
27 | };
|
28 |
|
29 | template <typename Container, typename... Types>
|
30 | struct Top
|
31 | {
|
32 | using sub_first_type = get_first<Types...>;
|
33 | using sub = Sub<Container, sub_first_type, Types.../*[1...]*/>;
|
34 | };
|
35 |
|
36 | using container = std::vector<int>;
|
37 | using top = Top<container, int, short, long>;
|
38 |
|
39 | static_assert(std::is_same<top::sub::first_type, int>::value, "wrong");
|
40 | // die Test gehen nicht weil ich immer das volle Parameter-Pack weiter reichen
|
41 | #if 0
|
42 | static_assert(std::is_same<top::sub, Sub<container, int, short, long>>::value, "wrong");
|
43 |
|
44 | static_assert(std::is_same<top::sub::sub::first_type, short>::value, "wrong");
|
45 | static_assert(std::is_same<top::sub::sub, Sub<container, short, long>>::value, "wrong");
|
46 |
|
47 | static_assert(std::is_same<top::sub::sub::sub::first_type, long>::value, "wrong");
|
48 | static_assert(std::is_same<top::sub::sub::sub, Sub<container, long>>::value, "wrong");
|
49 | #endif
|
50 |
|
51 | // sollte eher gar nicht gehen
|
52 | using sinnfrei = top::sub::sub::sub::sub::sub::sub;
|