C++ Logo

std-discussion

Advanced search

Re: std::chrono: intend of op-/ for std:.chrono::day

From: Wilhelm Meier <wilhelm.meier_at_[hidden]>
Date: Thu, 16 Jan 2020 16:10:40 +0100
Am 16.01.20 um 15:59 schrieb Ville Voutilainen:
> On Thu, 16 Jan 2020 at 16:50, Wilhelm Meier via Std-Discussion
> <std-discussion_at_[hidden]> wrote:
>>
>> Hi all,
>>
>> just stumbled across the following:
>>
>> auto t1 = 12s / 3;
>> auto t2 = 12d / 3;
>>
>> t1 gives a duration of 3 seconds (reasonable, but t2 gives 12th of march.
>>
>> Is this intentional?
>>
>> I know, that 12s is a duration, and 12d is a timepoint. But for the
>> careless reader, this is counter-intuitive.
>
> Yes, it's intentional, and allows you to write things like 12d/3/2020y.

Yes, I know that I can write 12d/3/2020y

But 12d/3 alone looks a bit strange an is in my opinion very
counter-intuitive and may be a future source of hidden errors.

Received on 2020-01-16 09:13:20