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 10:42:56 +0300
On Wed, 19 Jun 2024 at 09:30, Mateusz Pusz <mateusz.pusz_at_[hidden]> wrote:
>
> I did consider this, but it has many issues as well:
> - It is not consistent across the library as we would need other ways to spell derived units or even base units in some cases (see below).
> - It would be quite hard (or at least inconsistent with chrono) to specify and implement UDLs in such a way that they do not widen the types to the largest fundamental or floating-point type on arithmetic.
> - There is no way to disambiguate SI second and CGS second
> - With this even writing a unit of speed starts to be challenging.
>
> Right now we can type:
>
> quantity<m> length = 20 * m;
> quantity<km/s> speed = 60 * km / s;
>
> With UDLs it would have to be something like this:
>
> quantity<si::metre> length = 20m;
> quantity<si::kilo<si::metre> / si::second> speed = 60km / 1s;

Fascinating. I don't quite understand what would cause that, instead
of being able to do
quantity<km/s> speed = 60km / 1s;

Received on 2024-06-19 07:43:09