-
Notifications
You must be signed in to change notification settings - Fork 2
/
week13-app1.cpp
48 lines (29 loc) · 1 KB
/
week13-app1.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
46
47
48
// decltype(auto)
// get_int_byval(), get_int_byref()
// function object that calls the callable when called :)
// Tuple struct implementations
// lambdas capturing local variables: this includes local parameter packs as well
// storing parameter packs: an elegant storage container; get_first, get_size, get_tail impl.
// std::function<...> // type erasure
#include <iostream>
using namespace std;
auto get_int_byval() -> int { int i = 5; return i; }
auto get_int_byref() -> int& { static int i = 5; return i; }
template<typename Callable>
struct FuncObj {
void operator() (Callable callable) {
callable();
}
};
template<typename...>
struct Debug;
int main() {
auto value1 = get_int_byval(); // value1 -> int
auto value2 = get_int_byref(); // value2 -> int
decltype(auto) value3 = get_int_byval();
decltype(auto) value4 = get_int_byref();
// auto func1 = FuncObj< ... >{};
// decltype(auto) retval = func1();
// auto t = Debug<decltype(value4)>{};
return 0;
}