Closed
Description
Having the code
struct X {};
main: () -> int = {
x: X = ();
std::cout << "x = '(x)$'" << std::endl;
}
Expected
Output:
../tests/bug_cast_to_optional.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)
x = '(customize me - no cpp2::to_string overload exists for this type)'
Actual
../tests/bug.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)
x = 'std::any'
Cause
The X
type matches:
inline auto to_string(std::any const&) -> std::string {
return "std::any";
}
Possible fix
Replace the above overload to:
template<typename T>
requires std::is_same_v<T, std::any>
inline auto to_string(T const&) -> std::string {
return "std::any";
}