forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpure2-default-arguments.cpp2
More file actions
62 lines (52 loc) · 1.41 KB
/
Copy pathpure2-default-arguments.cpp2
File metadata and controls
62 lines (52 loc) · 1.41 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Note: Using source_location requires GCC 11 or higher,
// Clang 16 or higher, MSVC 2019 16.10 or higher.
// Older compilers will emit failures for this test case.
my_function_name: (
fn: *const char = std::source_location::current().function_name()
)
= {
std::cout << "calling: (fn)$\n";
}
f: (x: i32 = 0) = { std::cout << x; }
combine_maps:
<
AssocContainer,
Func: type = std::plus<>
>
(
inout map1: AssocContainer,
map2: AssocContainer,
func: Func = ()
)
= {
for map2 do(kv) {
map1[kv.first] = func(map1[kv.first], kv.second);
}
}
myclass: <T: type = int, N: int = 42> type = {
memfunc: <TT: type = int, NN: int = 42> (MM: int = 43) = { _ = MM; }
}
myfunc: <T: type = int, N: int = 42> (M: int = 43) = {
_ = M;
: <TT: type = int, NN: int = 42> (MM: int = 43) = { _ = MM; };
}
main: (args) = {
my_function_name();
f();
f(1);
f(2);
: <V: bool = gcc_clang_msvc_min_versions( 1400, 1600, 1920 )> () = {
if constexpr V {
std::cout << "\na newer compiler\n";
}
else {
std::cout << "\nan older compiler\n";
}
} ();
m1: std::map<int, int> = ();
m1[1] = 11;
m2: std::map<int, int> = ();
m2[1] = 22;
combine_maps( m1, m2, :(x,y) = x+y+33 );
std::cout << "(m1.size())$, (m2.size())$, (m1[1])$\n";
}