-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_getindex.cpp
46 lines (37 loc) · 887 Bytes
/
test_getindex.cpp
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
#include "getindex.h"
#include <stdio.h>
template <unsigned int... Is>
struct index_list {};
static inline void invoke()
{
}
template <typename Fn0,typename... Fns>
static inline void invoke(Fn0&& fn0,Fns&&... fns)
{
fn0();
invoke((Fns&&)fns...);
}
template <unsigned int... Is,typename... Fns>
void test1(index_list<Is...>,Fns&&... fns)
{
invoke(pack_tools::get_index<Is>((Fns&&)fns...)...);
}
template <unsigned int... Is,typename... Ts>
void test2(Ts&&... args)
{
{ const int k[]={printf("%s ",pack_tools::get_index<Is>(args...))...}; (void)k; } // (,0) not needed
}
int main(int argc,char **argv)
{
test1(index_list<1,0,1>(),[&](){
printf("1 %d\n",argc);
},[&](){
printf("2\n");
},[&](){
printf("3\n");
});
// printf("%s\n",pack_tools::get_index<0>("The","other","thing"));
test2<0,1,1,2>("The","other","thing");
printf("\n");
return 0;
}