mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

Should conversions from the raw numerical value to a dimensionless quantity with a unit one be allowed?

Open mpusz opened this issue 4 months ago • 26 comments

A few parties (including LEWG) were surprised that we have to write 42 * one to assign a raw value to a quantity. See also https://github.com/mpusz/mp-units/issues/497#issuecomment-1936660421.

This, of course, is consistent with the rest of the library and tries to prevent the cases where someone will initialize quantities measured in percentages or other dimensionless units from the raw value.

In 0.8.0, we had an exception for the dimensionless quantity of a unit one. Such quantity was implicitly convertible from a raw value. This was inconsistent with the handling of other units and increased the complexity of the design a bit, but it was user-friendly.

Should we add a similar feature to the 2.0 framework?

Should the conversion happen implicitly or explicitly? Should we also provide a conversion from quantity to a numerical value in such cases?

mpusz avatar Feb 10 '24 14:02 mpusz