@@ -24,12 +24,13 @@ class Square : public Shape { };
24
24
// --- printing helpers -----------------
25
25
26
26
#line 13 "mixed-type-safety-1.cpp2"
27
- auto print (cpp2::impl::in<std::string> msg, auto const & x) -> void;
27
+ template <typename T> auto print (cpp2::impl::in<std::string> msg, T const & x) -> void
28
+ CPP2_REQUIRES (!(std::convertible_to<T,bool >)) ;
28
29
29
- #line 16 "mixed-type-safety-1.cpp2"
30
+ #line 17 "mixed-type-safety-1.cpp2"
30
31
auto print (cpp2::impl::in<std::string> msg, cpp2::impl::in<bool > b) -> void;
31
32
32
- #line 24 "mixed-type-safety-1.cpp2"
33
+ #line 25 "mixed-type-safety-1.cpp2"
33
34
// --- examples -------------------------
34
35
35
36
[[nodiscard]] auto main () -> int;
@@ -39,10 +40,13 @@ auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void;
39
40
#line 1 "mixed-type-safety-1.cpp2"
40
41
41
42
#line 13 "mixed-type-safety-1.cpp2"
42
- auto print (cpp2::impl::in<std::string> msg, auto const & x) -> void {
43
+ template <typename T> auto print (cpp2::impl::in<std::string> msg, T const & x) -> void
44
+ requires (!(std::convertible_to<T,bool >)) {
45
+
46
+ #line 15 "mixed-type-safety-1.cpp2"
43
47
std::cout << msg << x << " \n " ; }
44
48
45
- #line 16 "mixed-type-safety-1.cpp2"
49
+ #line 17 "mixed-type-safety-1.cpp2"
46
50
auto print (cpp2::impl::in<std::string> msg, cpp2::impl::in<bool > b) -> void
47
51
{
48
52
cpp2::impl::deferred_init<char const *> bmsg;
@@ -51,7 +55,7 @@ auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void
51
55
std::cout << msg << cpp2::move (bmsg.value ()) << " \n " ;
52
56
}
53
57
54
- #line 26 "mixed-type-safety-1.cpp2"
58
+ #line 27 "mixed-type-safety-1.cpp2"
55
59
[[nodiscard]] auto main () -> int
56
60
{
57
61
print (" 1.1 is int? " , cpp2::impl::is<int >(1.1 ));
0 commit comments