Skip to content

Commit

Permalink
Work around requires support issue in GCC 10
Browse files Browse the repository at this point in the history
  • Loading branch information
jarzec committed Aug 22, 2024
1 parent 515d415 commit de2c399
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
5 changes: 3 additions & 2 deletions regression-tests/mixed-type-safety-1.cpp2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class Square : public Shape { };

//--- printing helpers -----------------

print: <T : type> ( msg: std::string, x: T )
requires !std::convertible_to<T, bool> =
non_bool: <T> concept = !std::convertible_to<T, bool>;

print: <T : non_bool> ( msg: std::string, x: T ) =
std::cout << msg << x << "\n";

print: ( msg: std::string, b: bool ) =
Expand Down

This file was deleted.

18 changes: 8 additions & 10 deletions regression-tests/test-results/mixed-type-safety-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ class Square : public Shape { };
//--- printing helpers -----------------

#line 13 "mixed-type-safety-1.cpp2"
template<typename T> auto print(cpp2::impl::in<std::string> msg, T const& x) -> void
CPP2_REQUIRES (!(std::convertible_to<T,bool>)) ;
template<typename T> concept non_bool = !(std::convertible_to<T,bool>);

#line 17 "mixed-type-safety-1.cpp2"
template<non_bool T> auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<T> x) -> void;

#line 18 "mixed-type-safety-1.cpp2"
auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void;

#line 25 "mixed-type-safety-1.cpp2"
#line 26 "mixed-type-safety-1.cpp2"
//--- examples -------------------------

[[nodiscard]] auto main() -> int;
Expand All @@ -39,14 +40,11 @@ auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void;

#line 1 "mixed-type-safety-1.cpp2"

#line 13 "mixed-type-safety-1.cpp2"
template<typename T> auto print(cpp2::impl::in<std::string> msg, T const& x) -> void
requires (!(std::convertible_to<T,bool>)) {

#line 15 "mixed-type-safety-1.cpp2"
template<non_bool T> auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<T> x) -> void {
std::cout << msg << x << "\n"; }

#line 17 "mixed-type-safety-1.cpp2"
#line 18 "mixed-type-safety-1.cpp2"
auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void
{
cpp2::impl::deferred_init<char const*> bmsg;
Expand All @@ -55,7 +53,7 @@ auto print(cpp2::impl::in<std::string> msg, cpp2::impl::in<bool> b) -> void
std::cout << msg << cpp2::move(bmsg.value()) << "\n";
}

#line 27 "mixed-type-safety-1.cpp2"
#line 28 "mixed-type-safety-1.cpp2"
[[nodiscard]] auto main() -> int
{
::print("1.1 is int? ", cpp2::impl::is<int>(1.1));
Expand Down

0 comments on commit de2c399

Please sign in to comment.