Named types for type level operators (error improvement 2) #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the previous error improvement, the units system was changed to generate named classes for quantities that can be used interchangeably with the structural
Quantity<>
type. This PR allows type level quantity manipulations such asMultiplied<Q1, Q2>
,Divided<Q1, Q2>
,Exponentiated<Q, N>
andRooted<Q, N>
to return the named classes (if possible) rather than the genericQuantity<>
class.It does this by generating a "compile time type function" from the corresponding
Quantity<>
class to it's named counterpart when theNEW_UNIT
macro is invoked. Then with this function we can created a wrapperNamed<Q>
that will produce the named version of a quantity type if it exists.For example this offending code:
previously generated this error:
with this change, it now generates this error: