-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpprouter.cpp
More file actions
65 lines (50 loc) · 1.43 KB
/
cpprouter.cpp
File metadata and controls
65 lines (50 loc) · 1.43 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<cstdlib>
#include<tuple>
#include<iostream>
#include "router.h"
template<typename... Ts>
std::ostream& operator<<(std::ostream& os, std::tuple<Ts...> const& theTuple)
{
std::apply
(
[&os](Ts const&... tupleArgs)
{
os << '[';
std::size_t n{0};
((os << tupleArgs << (++n != sizeof...(Ts) ? ", " : "")), ...);
os << ']';
}, theTuple
);
return os;
}
template <typename... T>
int sum(T... vals) {
return (vals + ...);
}
int main(int argc, char* argv[]) {
std::string text(argc > 1 ? argv[1] : "");
for(size_t i = 2; i < size_t(argc); ++i) {
text += " ";
text += argv[i];
}
Extras<int>::Route<int, int, float> route(
"hello %d world %d final %f",
[](int a, int b, float c, int extra) {
std::cout << a << " - " << b << " " << c << std::endl;
std::cout << extra << std::endl;
});
Route<int, int, float> route2(
"hello %d world %d final %f",
[](int a, int b, float c) {
std::cout << a << " - " << b << " " << c << std::endl;
});
// auto route = make_route<int, int, float>(
// "hello %d world %d final %f",
// [](int a, int b, float c) {
// std::cout << a << " - " << b << " " << c << std::endl;
// });
// route("hello 52 world 34 final 9.0");
route(text, 5);
route2(text);
return 0;
}