Skip to content

Commit 778ef24

Browse files
committed
is(): fix test when is() returns std::bool_constant
1 parent 7f6a912 commit 778ef24

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

regression-tests/mixed-type-safety-1.cpp2

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class Square : public Shape { };
1010

1111
//--- printing helpers -----------------
1212

13-
print: ( msg: std::string, x: _ ) =
13+
print: <T : type> ( msg: std::string, x: T )
14+
requires !std::convertible_to<T, bool> =
1415
std::cout << msg << x << "\n";
1516

1617
print: ( msg: std::string, b: bool ) =

regression-tests/test-results/mixed-type-safety-1.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ class Square : public Shape { };
2424
//--- printing helpers -----------------
2525

2626
#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>)) ;
2829

29-
#line 16 "mixed-type-safety-1.cpp2"
30+
#line 17 "mixed-type-safety-1.cpp2"
3031
auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void;
3132

32-
#line 24 "mixed-type-safety-1.cpp2"
33+
#line 25 "mixed-type-safety-1.cpp2"
3334
//--- examples -------------------------
3435

3536
[[nodiscard]] auto main() -> int;
@@ -39,10 +40,13 @@ auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void;
3940
#line 1 "mixed-type-safety-1.cpp2"
4041

4142
#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"
4347
std::cout << msg << x << "\n"; }
4448

45-
#line 16 "mixed-type-safety-1.cpp2"
49+
#line 17 "mixed-type-safety-1.cpp2"
4650
auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void
4751
{
4852
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
5155
std::cout << msg << cpp2::move(bmsg.value()) << "\n";
5256
}
5357

54-
#line 26 "mixed-type-safety-1.cpp2"
58+
#line 27 "mixed-type-safety-1.cpp2"
5559
[[nodiscard]] auto main() -> int
5660
{
5761
print("1.1 is int? ", cpp2::impl::is<int>(1.1));

0 commit comments

Comments
 (0)