We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using a std::basic_string with a custom allocator, it fails to compile in a few use cases, e.g.:
std::basic_string
std::string f1() { // This compiles. return fmt::format("{}", std::tuple<std::string>{}); } std::string f2() { // This compiles. return fmt::format("{}", std::pmr::string{}); } std::string f3() { // This does not compile. return fmt::format("{}", std::tuple<std::pmr::string>{}); }
You can reproduce the error here: https://godbolt.org/z/4oa1jqr1G
I checked the code, and it seems std::basic_string is specialized only for the default allocator. I think the fix might be as simple as replacing
FMT_FORMAT_AS(std::basic_string<Char>, basic_string_view<Char>);
with
template <typename Char, typename Alloc> class formatter<std::basic_string<Char, std::char_traits<Char>, Alloc>, Char> : public formatter<basic_string_view<Char>, Char> {};
It is also not clear why printing a std::pmr::string alone works. Maybe it's falling back to string_view while the tuple version is not.
std::pmr::string
string_view
The text was updated successfully, but these errors were encountered:
Thanks for reporting.
I checked the code, and it seems std::basic_string is specialized only for the default allocator. I think the fix might be as simple as replacing ...
That looks like the correct fix (modulo also making char_traits a template parameter). Could you submit a PR?
Sorry, something went wrong.
Sure thing!
formatter
Successfully merging a pull request may close this issue.
When using a
std::basic_string
with a custom allocator, it fails to compile in a few use cases, e.g.:You can reproduce the error here: https://godbolt.org/z/4oa1jqr1G
I checked the code, and it seems
std::basic_string
is specialized only for the default allocator. I think the fix might be as simple as replacingFMT_FORMAT_AS(std::basic_string<Char>, basic_string_view<Char>);
with
It is also not clear why printing a
std::pmr::string
alone works. Maybe it's falling back tostring_view
while the tuple version is not.The text was updated successfully, but these errors were encountered: