-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cpp
executable file
·40 lines (31 loc) · 877 Bytes
/
main.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
#include <iostream>
#include <utility>
#include <functional>
#include <string>
using void_fn_t = std::function<void()>;
template<class... Args>
void out(const Args&... args) {
(std::cout << ... << args) << std::endl;
}
template<class... Args>
void print(const Args&... args) {
std::function<void(const void_fn_t&)> wrapper = [] (const void_fn_t& fn) {
std::cout << "begin" << std::endl;
fn();
std::cout << "end;" << std::endl;
};
auto bound1 = [args = std::make_tuple(std::forward<const Args&>(args) ...)] () {
std::apply([](auto& ... args) {
out(args...);
}, args);
};
wrapper(bound1);
auto bound2 = std::bind(&out<const Args&...>, std::forward<const Args&>(args)...); // WTF?
}
int main() {
print("Hello, ", "World!");
// begin
// Hello, World!
// end;
return 0;
}