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

fmt::format_to + FMT_STRING with wide characters fails to compile #3925

Closed
hmbj opened this issue Apr 8, 2024 · 1 comment
Closed

fmt::format_to + FMT_STRING with wide characters fails to compile #3925

hmbj opened this issue Apr 8, 2024 · 1 comment

Comments

@hmbj
Copy link
Contributor

hmbj commented Apr 8, 2024

Using a wide character buffer, fmt::format_to with FMT_STRING fails to compile. Compiles fine using narrow character buffer.

// Using a 'char' buffer compiles as expected
std::string buf;
fmt::format_to(std::back_inserter(buf), FMT_STRING("{}"), 1);

// Using 'wchar_t' buffer fails to compile:
// opt/compiler-explorer/libs/fmt/trunk/include/fmt/xchar.h:190:48: error:
// no matching function for call to 'to_string_view(const main()::<lambda()>::FMT_COMPILE_STRING&)'
std::wstring wbuf;
fmt::format_to(std::back_inserter(wbuf), FMT_STRING(L"{}"), 2);  // this compiles without FMT_STRING

godbolt repro:
https://godbolt.org/z/h7Trrjf5M

@hmbj
Copy link
Contributor Author

hmbj commented Apr 9, 2024

The code above compiles successfully prior to this commit: 2e5b14b.

For example in {fmt} version 10.2.1, it compiles: https://godbolt.org/z/T7jd487rK

hmbj pushed a commit to hmbj/fmt that referenced this issue Apr 15, 2024
hmbj pushed a commit to hmbj/fmt that referenced this issue Apr 16, 2024
Added overload that takes a wformat_string.
Fixes issue fmtlib#3925.
vitaut pushed a commit that referenced this issue Apr 17, 2024
Added overload that takes a wformat_string.
Fixes issue #3925.
@vitaut vitaut closed this as completed Apr 17, 2024
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