Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4, 6.7.0
-
None
-
-
2
-
e95812df8 (dev), 6197078fb (6.7), 48ab909c5 (dev)
-
Foundation Sprint 108, Foundation Sprint 109, Foundation Sprint 110, Foundation Sprint 111, Foundation Sprint 112, Foundation Sprint 113, Foundation Sprint 114, Foundation Sprint 115, Foundation Sprint 116, Foundation Sprint 117, Foundation Sprint 118, Foundation Sprint 119, Foundation Sprint 120, Foundation Sprint 121, Foundation Sprint 122
Description
I cannot create a QDateTime object from a std TimePoint:
QDateTime::fromStdTimePoint(std::chrono::system_clock::now())
This snippet does not compile on Windows, because of the constraints:
requires(const std::chrono::time_point<Clock, Duration> &t) { // the clock can be converted to system_clock std::chrono::clock_cast<std::chrono::system_clock>(t); // the duration can be converted to milliseconds requires std::is_convertible_v<Duration, std::chrono::milliseconds>; }
The Duration type of the system clock's time point is implementation defined. In may case (VS2022) it is probably larger than std::chrono::milliseconds, so it cannot be implicitly converted.
Since the implementation uses a std::chrono::time_point_cast anyways, maybe the constraint can be dropped (or maybe use the time_point_cast inside the requires clause).
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-125587 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
563189,3 | Relax duration precision in QDateTime::fromStdTimePoint | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
563410,6 | QDateTime::fromStdTimePoint: fix the constraint | dev | qt/qtbase | Status: MERGED | +2 | 0 |
563496,4 | QDateTime::fromStdTimePoint: remove an unnecessary time_point_cast | dev | qt/qtbase | Status: MERGED | +2 | 0 |
564142,2 | QDateTime::fromStdTimePoint: fix the constraint | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |