Closed dangelog closed 2 months ago
For user-defined representation types, see also microsoft/STL#1909. The requirement "a class emulating an arithmetic type" ([tab:time.clock]) is too imprecise to be honored by implementations.
I'd agree. I'm going to open a library defect for that.
This excludes unsigned types as well as any user-defined representation type.
Not if you specialize numeric_limits
for your user-defined rep, which is probably a good idea for something trying to act like a numeric type (and means you don't need to specialize chrono::duration_values
).
Actually it seems there are other issues with this formatter. [time.duration.general]/2
Rep shall be an arithmetic type or ...
This allows Rep
to be unsigned char
, bool
, char8_t
, etc. These duration specializations then should be streamed to an ostream
. unsigned char
is on its way to be deprecated by P3154R1 and char8_t
does not work. (There might be other issues too.)
For now I'll look at unsigned short
, unsigned
, unsigned long
, and unsigned long long
.
I hope to find time to write an LWG-issue/paper to discuss whether arithmetic types is the proper set.
@dangelog can you post the LWG number here once you have one?
This allows
Rep
to beunsigned char
,bool
,char8_t
, etc. These duration specializations then should be streamed to anostream
.unsigned char
is on its way to be deprecated by P3154R1 andchar8_t
does not work. (There might be other issues too.)
Yes, I have a draft LWG issue on that topic. The formatter for durations needs to be constrained to only accept formattable rep types.
Hi,
@dangelog can you post the LWG number here once you have one?
Turns out that there were already a couple of defects in the area, jwakely kindly pointed me to them:
https://cplusplus.github.io/LWG/issue951 https://cplusplus.github.io/LWG/issue953
I still think that more clarifications are needed in the area...
Testcase: https://godbolt.org/z/EM7WxfEfT
Does not build:
chrono::abs
is constrained for durations whose representation type is signed. This excludes unsigned types as well as any user-defined representation type.Matching bug in libstdc++: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115668