refactor(core): replace `convert_*` wrappers with a member query
Title: refactor(core): replace convert_* wrappers with a member query.
Description:
Replace https://github.com/mpusz/mp-units/blob/89bafed9619a4a8320046e2be621172a6e88b586/src/core/include/mp-units/framework/customization_points.h#L144-L162 with these members in the quantity-like-traits templates:
static constexpr bool to_numerical_value_is_explicit = false;
static constexpr bool from_numerical_value_is_explicit = false;
That removes the need to wrap and unwrap the numbers,
and simplifies the expressions in the explicit specifiers.
This will also require updating
- their use in the quantity templates,
- the
std::chronosupport, - their own tests,
- any use in the examples, and
- the user guide documentation.
Naming is hard 😉:
- This does not control the convertibility to/from a numerical value, but to /from
quantity/quantity_point. I do not have a good idea of how to rename this, though. - Should we mention "explicit" or "implicit" in the identifier?
- Maybe we should be consistent with
is_transparentand provide a type instead of theboolvalue instead? - Should both flags be
trueby default and not have to be provided in such case? Or should we always specify them and mandate this in a concept?
Naming is hard 😉:
- This does not control the convertibility to/from a numerical value, but to /from
quantity/quantity_point. I do not have a good idea of how to rename this, though.
I'm still thinking.
- Should we mention "explicit" or "implicit" in the identifier?
Explicit to avoid negations in the explicit specifiers.
- Maybe we should be consistent with
is_transparentand provide a type instead of theboolvalue instead?
That just makes the explicit specifiers harder to specify.
- Should both flags be
trueby default and not have to be provided in such case? Or should we always specify them and mandate this in a concept?
I prefer explicitly requiring them.
Maybe:
static constexpr bool to_quantity_is_explicit = false;
static constexpr bool from_quantity_is_explicit = false;
and
static constexpr bool to_quantity_point_is_explicit = false;
static constexpr bool from_quantity_point_is_explicit = false;
?
The problem I have with that is that the "like" parameter is also a quantity (point). So the direction is still confusing, "from our quantity, or their quantity?".
You can also say that those also have some numerical value 😉
I could argue that that others are not "quantities" but duration or MyMetre. Unless it is about the cooperation with Au which uses proper names 😉
So maybe:
static constexpr bool explicit_import = false;
static constexpr bool explicit_export = false;
?
Naming is hard 😉
It seems like this was fixed by commit 975025f88a3f58ffc39ca4a4100f40d6a8ca5eff.