-
Notifications
You must be signed in to change notification settings - Fork 29
Switch Au to new operation-based implementation #472
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
Conversation
We update `:quantity` so that it simply asks for the right conversion, and applies it. Then, now that we know that `:quantity` is using operations, we can update `:conversion_policy` to use those operations to check for overflow and truncation risk. This lets us get rid of the `:apply_rational_magnitude_to_integral`, `:apply_magnitude`, and `:static_cast_checkers` libraries, because we no longer use them anywhere. However, we retain their _test files_, by sticking a very short implementation (based on the new libraries) at the top of each test file. This way, we still get value from all those old test cases: they give us confidence that we executed the switch correctly. Fixes #349.
| namespace detail { | ||
| namespace { | ||
|
|
||
| // `NewOverflowChecker<Op>::would_product_overflow(x)` checks whether the value `x` would exceed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a similar comment about these being from an older library? Obviously git history can be used to check that out, but that would explain the differing idiom for the unit tests (normally they have a corresponding library that they are testing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! These files would look really weird otherwise. Done.
|
|
||
| namespace detail { | ||
|
|
||
| template <typename U, typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment about the previous library implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
We update
:quantityso that it simply asks for the right conversion,and applies it. Then, now that we know that
:quantityis usingoperations, we can update
:conversion_policyto use those operationsto check for overflow and truncation risk.
This lets us get rid of the
:apply_rational_magnitude_to_integral,:apply_magnitude, and:static_cast_checkerslibraries, because we nolonger use them anywhere. However, we retain their test files, by
sticking a very short implementation (based on the new libraries) at the
top of each test file. This way, we still get value from all those old
test cases: they give us confidence that we executed the switch
correctly.
Fixes #349.