-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Given some units defined as such1:
struct PerMille : decltype(Percent{} / mag<10>());
struct PerMyriad : decltype(PerMille{} / mag<10>());
struct PerCentMille : decltype(PerMyriad{} / mag<10>());
struct PartsPerMillion : decltype(PerCentMille{} / mag<10>());
struct PartsPerBillion : decltype(PartsPerMillion{} / mag<1'000>());
struct PartsPerTrillion : decltype(PartsPerBillion{} / mag<1'000>());
struct PartsPerQuadrillion : decltype(PartsPerTrillion{} / mag<1'000>());
struct PartsPerQuintillion : decltype(PartsPerQuadrillion{} / mag<1'000>());
Trying to assign from a QuantityI64<PartsPerQuintillion>
to a QuantityI64<PartsPerBillion>
results in an error message that says there isn't a constructor available:
note: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Quantity<av::embedded::firmware::protocol::ptp::PartsPerQuintillion, [...]>' to 'Quantity<av::embedded::firmware::protocol::ptp::PartsPerBillion, [...]>' for 1st argument
Manually requesting the conversion using .as(PartsPerBillion{})
yields a more useful error:
error: static assertion failed due to requirement 'IMPLICIT_OK': Dangerous conversion for integer Rep! See: https://aurora-opensource.github.io/au/main/troubleshooting/#dangerous-conversion
Which can then be resolved with a .coerce_as
. It would be useful to get the conversion error in the first instance.
Footnotes
Metadata
Metadata
Assignees
Labels
No labels