You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: regression-tests/mixed-overview-of-as-casts.cpp2
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -58,10 +58,13 @@ main: () = {
58
58
vc: VC = ();
59
59
vp0 : *VA<0> = vc&;
60
60
vp1 : *VA<1> = vc&;
61
+
cvp0 : * const VA<0> = vc&;
61
62
62
63
print("( vp0 as *VC ) is (vc&)", ( vp0 as *VC ) is (vc&), true);
63
64
print("( vp1 as *VC ) is (vc&)", ( vp1 as *VC ) is (vc&), true);
64
65
print("( vp0 as *VA<1> ) is (vp1)", ( vp0 as *VA<1> ) is (vp1), true);
66
+
print("( cvp0 as *VC ) is (std::as_const(vc)&)", ( cvp0 as *VC ) is (std::as_const(vc)&), true );
67
+
print("( cvp0 as * const VC ) is (std::as_const(vc)&)", ( cvp0 as * const VC ) is (std::as_const(vc)&), true );
65
68
66
69
print("( vp0* as VC )& is (vc&)", ( vp0* as VC )& is (vc&), true);
67
70
print("( vp1* as VC )& is (vc&)", ( vp1* as VC )& is (vc&), true);
@@ -126,6 +129,15 @@ main: () = {
126
129
print("( o{42} as long ) is (42l)", ( o as long ) is (42l), true);
127
130
print("( o{42} as std::tuple<long> ) is (std::tuple<long>(42))", ( o as std::tuple<long> ) is (std::tuple<long>(42)), true);
128
131
}
132
+
133
+
{// string
134
+
print("( \"xyzzy\" as std::string ) is std::string", ( "xyzzy" as std::string ) is std::string, true, "xyzzy" as std::string);
135
+
print("( std::string(\"xyzzy\") as std::string ) is std::string", ( std::string("xyzzy") as std::string ) is std::string, true, std::string("xyzzy") as std::string);
136
+
s : std::string = "string";
137
+
138
+
print("( as_const(s){string} as std::string ) is std::string", ( std::as_const(s) as std::string ) is std::string, true);
139
+
print("( s{string} as std::string ) is std::string", ( s as std::string ) is std::string, true);
print("( vp0 as *VC ) is (vc&)", cpp2::is((cpp2::as_<VC*>(vp0)), (&vc)), true);
187
188
print("( vp1 as *VC ) is (vc&)", cpp2::is((cpp2::as_<VC*>(vp1)), (&vc)), true);
188
189
print("( vp0 as *VA<1> ) is (vp1)", cpp2::is((cpp2::as_<VA<1>*>(vp0)), (vp1)), true);
190
+
print("( cvp0 as *VC ) is (std::as_const(vc)&)", cpp2::is((cpp2::as_<VC*>(cvp0)), (&std::as_const(vc))), true);
191
+
print("( cvp0 as * const VC ) is (std::as_const(vc)&)", cpp2::is((cpp2::as_<VC const*>(std::move(cvp0))), (&std::as_const(vc))), true);
189
192
190
193
print("( vp0* as VC )& is (vc&)", cpp2::is(&(cpp2::as_<VC>(*cpp2::assert_not_null(vp0))), (&vc)), true);
191
194
print("( vp1* as VC )& is (vc&)", cpp2::is(&(cpp2::as_<VC>(*cpp2::assert_not_null(vp1))), (&vc)), true);
@@ -250,11 +253,20 @@ auto main() -> int{
250
253
print("( o{42} as long ) is (42l)", cpp2::is((cpp2::as_<long>(o)), (42l)), true);
251
254
print("( o{42} as std::tuple<long> ) is (std::tuple<long>(42))", cpp2::is((cpp2::as_<std::tuple<long>>(std::move(o))), (std::tuple<long>(42))), true);
252
255
}
256
+
257
+
{// string
258
+
print("( \"xyzzy\" as std::string ) is std::string", cpp2::is<std::string>((cpp2::as_<std::string>("xyzzy"))), true, cpp2::as_<std::string>("xyzzy"));
259
+
print("( std::string(\"xyzzy\") as std::string ) is std::string", cpp2::is<std::string>((cpp2::as_<std::string>(std::string("xyzzy")))), true, cpp2::as_<std::string>(std::string("xyzzy")));
260
+
std::string s {"string"};
261
+
262
+
print("( as_const(s){string} as std::string ) is std::string", cpp2::is<std::string>((cpp2::as_<std::string>(std::as_const(s)))), true);
263
+
print("( s{string} as std::string ) is std::string", cpp2::is<std::string>((cpp2::as_<std::string>(std::move(s)))), true);
0 commit comments