FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppfront/regression-tests/mixed-inspect-templates.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-templates.cpp2
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (35 loc) · 1.31 KB
Breadcrumbs
cppfront
/
regression-tests
/
mixed-inspect-templates.cpp2
Copy path
File metadata and controls
41 lines (35 loc) · 1.31 KB
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
#include <vector>
#include <array>
#include <string>
template <typename A, typename B>
struct my_type {};
fun: (v : _) -> std::string = {
return inspect v -> std::string {
is std::vector = "std::vector";
is std::array = "std::array";
is std::variant = "std::variant";
is my_type = "my_type";
is _ = "unknown";
};
}
fun2: (v : _) -> std::string = {
if v is std::vector { return "std::vector"; }
if v is std::array { return "std::array"; }
if v is std::variant { return "std::variant"; }
if v is my_type { return "my_type"; }
return "unknown";
}
main: () -> int = {
vec : std::vector<int> = (1,2,3);
arr : std::array<int,4> = (1,2,3,4);
var : std::variant<int, double, std::string> = ("C++ rulez");
myt : my_type<int, double> = ();
std::cout << "inspected vec : (fun(vec))$" << std::endl;
std::cout << "inspected arr : (fun(arr))$" << std::endl;
std::cout << "inspected var : (fun(var))$" << std::endl;
std::cout << "inspected myt : (fun(myt))$" << std::endl;
std::cout << "inspected vec : (fun2(vec))$" << std::endl;
std::cout << "inspected arr : (fun2(arr))$" << std::endl;
std::cout << "inspected var : (fun2(var))$" << std::endl;
std::cout << "inspected myt : (fun2(myt))$" << std::endl;
}
Back
|
FazBrowse Home
|
New Git URL