C++ Logo

std-proposals

Advanced search

Re: [std-proposals] On the standardization of mp-units P3045R1

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 18 Jun 2024 18:43:09 +0300
On Tue, 18 Jun 2024 at 18:38, Mateusz Pusz via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Multiply syntax will always create a quantity. So if I write:
>
> auto q = 4 * deg_C;
>
> I will end up with a delta temperature equal to 4 K.
>
> quantity q = 4 * deg_C; // the same thing as above
>
> If I try:
>
> quantity_point qp = 4 * deg_C;
>
> I will get a compile-time error as a quantity_point is not implicitly constructible from the quantity.
>
> To create a quantity_point, I have to do one of the following:
>
> quantity_point qp1 = zeroth_degree_Celsius + 4 * deg_C;
> quantity_point qp2(4 * deg_C, zeroth_degree_Celsius);
> quantity_point qp3(4 * deg_C); // proper point origin provided by default
>
> All of the above will create a temperature point with a value equal to 277.15 K.

..and chrono allows creating objects of such types with a literal,
whereas this library doesn't?

Received on 2024-06-18 15:43:22