Compare underlying values of hetereogeneous types #432
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.
Formerly, in
Quantity, we used aCompareUnderlyingValueshelper,and a
UnitSignenum. The helper was responsible for taking twoidentical
Quantitytypes, and extracting their values. (We builtout this machinery to support negative units.)
Now, we refactor to use a new helper,
SignAwareComparison. Thisbrings two simplifications and one generalization.
Simplification: stop doing the extraction in the helper; let the
callers extract and pass the values. (This gives the helper just one
responsibility: namely, take the unit sign into account when deciding
which order to pass the parameters.)
Simplification: lose the enum; just use the new
UnitSigntrait.Generalization: accept heterogeneous parameters.
This last change will allow us to detect when we are passing mixed
signed and unsigned integral arguments. Of course, this PR is a no-op
refactor, so we're not actually taking advantage of this yet. That will
come in a follow-on PR.
Helps #428.