Skip to content
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

Ambiguous functions with ostream.h and const char * conversion #1309

Closed
EmilyMansfield opened this issue Sep 13, 2019 · 1 comment
Closed

Comments

@EmilyMansfield
Copy link

I'm working with some legacy code that defines a type with an implicit conversion to const char *, but I also have types with an operator<<. Including both ostream.h and format.h causes a compile error on GCC and Clang due to an ambiguous call to map, for example

#include <fmt/format.h>
#include <fmt/ostream.h>

struct MyBadType {
    operator const char *() const { return "whoops"; }
};

int main() {
    std::string s = fmt::format("{}", MyBadType{});
}

Godbolt: https://godbolt.org/z/XkXue4

fails to compile.

@vitaut
Copy link
Contributor

vitaut commented Sep 23, 2019

Fixed in f299010. Thanks for reporting!

@vitaut vitaut closed this as completed Sep 23, 2019
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

No branches or pull requests

2 participants