https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113500
Bug ID: 113500
Summary: Using std::format with float or double based
std::chrono::time_point causes error: no match for
'operator<<'
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
Consider the following code snippet:
---
using Representation = double;
using Duration = std::chrono::duration<Representation>;
using Clock = std::chrono::system_clock;
using TimePoint = std::chrono::time_point<Clock, Duration>;
TimePoint tp = {};
std::string time_string = std::format("{:%d.%m.%Y %H:%M:%S}", tp);
---
This results in the compile error:
---
error: no match for 'operator<<' (operand types are
'std::__cxx11::basic_ostringstream<char>' and 'const
std::chrono::time_point<std::chrono::_V2::system_clock,
std::chrono::duration<float> >')
726 | __os << __t;
| ~~~~~^~~~~~
---
If you change the type def `Representation` to an integer or unsigned integer
type, the code compiles.
System Info:
~~~
OS: Ubuntu 22.04 LTS
GCC-Version: 13.1.0
arguments: -std=c++20
~~~
Here is a link with the code that produces the error in Compiler Explorer:
https://godbolt.org/z/hhPrG1z37
Side note:
Don't know if it helps, but the latest clang compiler version produces the same
error. The related bug report can be found here:
https://github.com/llvm/llvm-project/issues/78555