-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add labels for integer and rational magnitudes
Think of this as "just enough of #85 to unblock #105". The fact that our common unit labels don't tell you the _size_ of the unit (#105) has really, really been bugging me for a long time. Recently, I realized we don't need to do all of #85 to get it! Instead, all we need to do is: 1. Build a _mechanism_ that we can easily _extend_. 2. Cover the most important use cases. This PR creates the `MagnitudeLabel` trait mechanism (also accessible via a function/value interface as `mag_label`). We enumerate the various categories of magnitudes that we can label, defaulting to "unsupported". The first two supported categories are _integers_ (that fit in `std::uintmax_t`), and _rationals_. We also add a trait, `has_exposed_slash`, looking forward to the obvious use case of auto-generating labels for scaled units. Those labels will have the form `"[M U]"` for a unit of label `"U"` scaled by a magnitude of label `"M"`. If `has_exposed_slash` is `true` for a given magnitude label, then we'll know to make this `"[(M) U]"` instead. Finally, we move a couple of `StringConstant`-ish utilities into `"string_constant.hh"`, so that we can use them in our implementation. Helps #85.
- Loading branch information
Showing
4 changed files
with
117 additions
and
9 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