CPP
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
#include <iostream>
#include <functional>
using namespace std;
template <class F, class... Args>
void takes_any_func(F&& func, Args&&... args)
{
cout << __PRETTY_FUNCTION__ << endl;
cout << "Calling func with args:\n";
func(args...);
/*
the above line can result in decayed references. It would actually be done soemthing like this
std::invoke(
std::forward<F>(func),
std::forward<Args>(args)...
);
*/
}
void f1(int a, int b, int c) {
cout << "f1: a+b+c = " << (a+b+c)
<< endl;
}
const auto f2 = [](auto... args) {
cout << "f2: args => ";
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run