-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
44 lines (31 loc) · 777 Bytes
/
test.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
#include "Expected.hpp"
#include "Pipe.hpp"
#include <iostream>
Expected<int> f(int a) {
std::cout << "running f\n";
return a * a;
}
Expected<int> d(int a) {
std::cout << "running d\n";
return a + a;
}
Expected<int> e(int a, int b) {
std::cout << "running e\n";
return {};
//return a + b;
}
auto myFunc = [](int a) -> Expected<int> {
std::cout << "runing myFunc\n";
return a + a;
};
int main() {
Expected<int> result = Expected<int>(5) | f | d;
Expected<int> res = (f(3), d(5)) | e | myFunc;
Expected<int> r = (f(3), d(5)) | e | [](int a){
std::cout << "running lambda\n";
return e(a, a);
};
//std::cout << "r: " << r.value() << "\n";
std::cout << result.value() << "\n";
return 0;
}