C++ Logo

std-proposals

Advanced search

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

From: Mateusz Pusz <mateusz.pusz_at_[hidden]>
Date: Tue, 18 Jun 2024 17:44:23 +0200
Exactly!

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3045r1.html#why-dont-we-use-udls-to-create-quantities

wt., 18 cze 2024 o 17:43 Ville Voutilainen <ville.voutilainen_at_[hidden]>
napisaƂ(a):

> 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:44:36