fmt
fmt copied to clipboard
`format_as` fails when called with certain `std::views`
Reproduction
Summary
A format_as
definition that returns a std::views::filter_view
, like so:
auto format_as(CodecMask m) {
return CodecMask::k_codecs | std::views::filter([&](auto c) { return m.has(c); });
}
does not compile:
CodecMask m;
m.add(Codec::H264);
fmt::println("{}", format_as(m)); // valid
fmt::pritnln("{}", m); // invalid
Stack Overflow
I posted this to stack overflow originally, expecting some mistake of my own. People there suggested that this may be a bug with fmt
itself, hence this issue. The explanation given there may prove to be of value.
Notes
I expected the most recent commit (274ba26) may have helped, as it appears to be related to this type of issue. It is worth noting the error message changes when tested against 10.1.1
and trunk
in godbolt, but both still do fail.
There is a simpler repro for the set_debug_format
error in https://github.com/fmtlib/fmt/issues/3763#issue-2048061455.
Understood, closing as duplicated!
Let's keep this one open for tracking the issue.
The set_debug_format
issue is fixed in https://github.com/fmtlib/fmt/commit/3eb3aef5753b91d689b496a629b9dc5c4a7cd348 but looks like there is another problem.
@vitaut This issue should be fixed by #3955
The original repro compiles now: https://godbolt.org/z/ahh86ME13. Thanks @Arghnews for the fix!