Add compatibility utility for nholthaus units #112
Merged
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.
This creates a file,
"compatibility/nholthaus_units.hh"
, which makesit easy to set up a correspondence between each Au Quantity type, and
the corresponding nholthaus units type. This "correspondence" includes
bidirectional implicit conversions: so, you can pass
::au::QuantityD<Meters>
to an API expecting::units::length::meter_t
, and vice versa.This correspondence is purely opt-in. The file also needs to be
included after both of the other two libraries are included. Since
this is fragile in general, we give instructions and an example for how
to make it not fragile, in
nholthaus_units_example_usage.hh
.We include a variety of unit tests to show that the quantities are
indeed equivalent between the libraries. (Actually, this isn't quite
always the case. These tests uncovered a bug in the nholthaus library,
nholthaus/units#289.)
We reserve the documentation of the corresponding-quantity feature in
general, as well as its application to the nholthaus library, for a
future PR.
Test plan