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

user-defined types with overloaded operator<< don't work after 7.0.3 #2014

Closed
odygrd opened this issue Nov 12, 2020 · 5 comments
Closed

user-defined types with overloaded operator<< don't work after 7.0.3 #2014

odygrd opened this issue Nov 12, 2020 · 5 comments

Comments

@odygrd
Copy link

odygrd commented Nov 12, 2020

It looks like that user defined types with an overloaded operator<<, no longer work when they are used in a container.

Broken example with fmt 7.1.x

https://godbolt.org/z/z1jn66

the same example compiles fine with fmt 7.0.x

https://godbolt.org/z/Wqbjsf

@odygrd odygrd changed the title user-defined types with overloaded operator<< error after 7.0.3 user-defined types with overloaded operator<< don't work after 7.0.3 Nov 12, 2020
@MikeGitb
Copy link

MikeGitb commented Nov 12, 2020

I'm having the same problem with user defined types that have an implicit conversion to std::string_view:

https://godbolt.org/z/EWfo1h

#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/ranges.h>

#include <string_view>

struct Foo {
    operator std::string_view() const { return "Hello";}
};

int main() {
    std::vector<Foo> v(5);
    fmt::print("{}", v);
}

@vitaut
Copy link
Contributor

vitaut commented Nov 19, 2020

This is caused by 2f7e088. We should probably add support for the fallback_formatter there.

@odygrd
Copy link
Author

odygrd commented Nov 21, 2020

It would be nice if this is fixed as part of the next release, it has broken backward compatibility with the previous fmt versions

@vitaut
Copy link
Contributor

vitaut commented Nov 21, 2020

Yes, that's the plan.

@vitaut
Copy link
Contributor

vitaut commented Nov 22, 2020

Fixed in a036cc9.

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

3 participants