https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113500

--- Comment #5 from hirtham...@allterra-dno.de ---
(In reply to Jonathan Wakely from comment #4)
> MSVC rejects this the same way, although libc++ from LLVM 17 compiles it.
> 
> AFAICT std::format("{}", tp) would be invalid because that formats tp by
> writing to a stream, and there is no operator<< for
> sys_time<duration<floating-point>>.
> 
> Arguably, std::format("{:%S}", tp) could work, because it doesn't need to
> use operator<< but the problem is that we can't detect at compile-time
> whether or not we need to use operator<< for a given format string. So it
> always fails to compile.
> 
> The reason it works with libc++ is because they have a bug in their
> operator<< for sys_time.
> 
> I think libstdc++ is correct here, but I've asked the C++ committee whether
> we might want to change the standard to support this case.

This whole thing with std::format and std::chrono::time_point is currently a
total minefield. In MSVC it is even more complicated and I already reported the
bug in October 2023. See:

https://developercommunity.visualstudio.com/t/Using-std::format-with-unsigned-integer-/10501153

If you change the clock to utc_clock or gps_clock the code compiles with MSVC
(but not with GCC) on Compiler Explorer.

I don't know much about the exact definitions of the standard. But I find it
very confusing if std::format generally supports a std::chrono::time_point as
an input, but depending on the chosen template arguments of the time_point it
does or does not compile.

Reply via email to