-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to constrain a derived unit for a specific quantity kind? #620
Comments
The same could be used to constrain |
There are several problems here:
|
This is backwards.
|
Well, it has at least two problems as well:
|
You're right, quantities are unit-agnostic in the ISQ. A number and a reference together form a quantity value. In Or you can make |
Interesting approach 😉 |
By this, I think making what a quantity kind does for quantity, but for units. If inline constexpr struct fuel_consumption final : quantity_spec<isq::volume / isq::length> {} fuel_consumption; makes static_assert(!castable(q2.quantity_spec, isq::area)); work, inline constexpr struct l_per_100km final : unit_spec<si::litre / (mag<100> * si::kilo<si::metre>)> {} l_per_100km; could make quantity q4 = q2.in(m2);
quantity q5 = isq::area(42 * l_per_100km);
quantity<isq::area[m2]> q6 = 42 * l_per_100km; not work. |
I am afraid that even though it could improve the case here, it would break plenty of other use cases. For example, https://mpusz.github.io/mp-units/latest/users_guide/framework_basics/systems_of_units/#many-shades-of-the-same-unit. Units have very different rules than quantities, and we probably should not try them to work the same. |
Just leave those units and examples untouched. |
Side question: for something like |
We never simplified |
I just played with a simple example:
it was really nice until now, but then I noticed that I can do the following 😱:
Do we have any ideas on how to improve here?
The text was updated successfully, but these errors were encountered: