C++ Logo

std-proposals

Advanced search

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

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Wed, 19 Jun 2024 00:36:14 +0300
On Tue, 18 Jun 2024 at 18:44, Mateusz Pusz <mateusz.pusz_at_[hidden]> wrote:
>
> Exactly!
>
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3045r1.html#why-dont-we-use-udls-to-create-quantities

Perhaps the library could entertain providing literals for the SI base
units, and not for combinations.

>
> 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 21:36:28