Skip to content

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

Closed
@hmbj

Description

@hmbj

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions