C++ Logo

std-discussion

Advanced search

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

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Thu, 16 Jan 2020 16:59:35 +0200
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.

Received on 2020-01-16 09:02:19