Skip to content

Fix to_string(std::any) overload #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

filipsajdak
Copy link
Contributor

Closes #200

Having the code

struct X {};

main: () -> int = {
    x: X = ();

    std::cout << "x  = '(x)$'" << std::endl;
}

Currently, end with:

../tests/bug.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)

x  = 'std::any'

But should with:

../tests/bug.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)

x  = '(customize me - no cpp2::to_string overload exists for this type)'

This change replace the problematic `cpp2::to_string(std::any)z overload to:

template<typename T>
    requires std::is_same_v<T, std::any>
inline auto to_string(T const&) -> std::string {
  return "std::any";
}

And fix one regression test.

@filipsajdak filipsajdak force-pushed the fsajdak-correct-to_string_std_any_overload branch from e7c6a67 to 76dfe88 Compare January 6, 2023 17:00
@hsutter
Copy link
Owner

hsutter commented Jan 6, 2023

Thanks!

@hsutter hsutter merged commit 7606052 into hsutter:main Jan 6, 2023
@filipsajdak filipsajdak deleted the fsajdak-correct-to_string_std_any_overload branch January 6, 2023 18:47
Azmah-Bad pushed a commit to Azmah-Bad/cppfront that referenced this pull request Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] to_string(...) hidden by to_string(std::any) overload
3 participants