-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make most unit traits compatible with unit slots (#168)
The motivating use case was `unit_ratio`. I was working with an ad hoc type for CPU frequency which _only_ had a quantity maker. See the example from the issue: ```cpp constexpr auto cpu_ticks = hertz * mag<400'000'000>(); ``` Right now, there's no good way to get the unit ratio between this and `Nano<Seconds>`. Enabling `unit_ratio(cpu_ticks, nano(seconds))` seems like a slam dunk. There are of course many other unit traits. I decided to update them all while I was in there. `is_unit` felt like it should be an exception, so I made it one, and explained why in detail in the docs. I also added test cases to make sure we have the desired behaviour. In doing so, I replaced our ad hoc definitions with the direct unit definitions. Making a length system based on `Feet` was kind of cute, but we don't need it. This also brings in the quantity makers such as `feet`, which was the real motivation for this change. I kept `Celsius` as-is because several tests depend on its exact choice of type for origin, and they're easier to understand if the definition is in the same file. Fixes #167.
- Loading branch information
Showing
4 changed files
with
129 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters