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 11:00:20 +0300
On Wed, 19 Jun 2024 at 10:52, Mateusz Pusz <mateusz.pusz_at_[hidden]> wrote:
>
> Sorry if I didn't understand your intent. I thought that instead of unit symbols you want to use UDLs.

60km / 1s;

is using UDLs.

quantity<km/s> speed = 60km / 1s;

is using both unit symbols and UDLs. I have no problem with that, it's
not a case of "instead".

>Unit symbols are mostly useful as quantity construction helpers. They are useful, but they also introduce a lot of very short identifiers that may shadow user's variables. That is why they are opt-in in a separate namespace.
>
> If you wanted to have units, unit symbols, and unit UDLs, then yes, the code you provided would be correct. But still, there are some other issues ;-)
>
> Today we can write things like:
>
> auto w = 40 * isq::width[m];
>
> auto h = 10 * isq::height[m];
>
> to get specialized quantities of length. With UDLs it would be impossible.

I'm not asking for UDLs as a replacement for unit symbols. I'm asking
for them as an amendment, as a convenient way to to create a
particular
quantity_point.

Received on 2024-06-19 08:00:33