FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppfront/regression-tests/mixed-inspect-values-2.cpp2 at main · iopenstack/cppfront · GitHub
iopenstack
/
cppfront
Public
forked from
hsutter/cppfront
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppfront
/
regression-tests
/
mixed-inspect-values-2.cpp2
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (34 loc) · 920 Bytes
Breadcrumbs
cppfront
/
regression-tests
/
mixed-inspect-values-2.cpp2
Copy path
File metadata and controls
45 lines (34 loc) · 920 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#include <iostream>
#include <vector>
constexpr auto less_than = [](int value) {
return [=](auto x) { return x < value;};
};
constexpr auto in = [](auto min, auto max) {
return [=](auto x) {
return min <= x && x <= max;
};
};
constexpr auto empty = [](auto&& x){
return std::empty(x);
};
main: () -> int = {
i := 15;
std::cout << inspect i -> std::string {
is (less_than(10)) = "i less than 10";
is (in(11,20)) = "i is between 11 and 20";
is _ = "i is out of our interest";
} << std::endl;
if i is (less_than(20)) {
std::cout << "less than 20" << std::endl;
}
if i is (in(10,30)) {
std::cout << "i is between 10 and 30" << std::endl;
}
v : std::vector<int> = ();
if empty(v) {
std::cout << "v is empty" << std::endl;
}
if v is (empty) {
std::cout << "v is empty" << std::endl;
}
}
Back
|
FazBrowse Home
|
New Git URL