aurora-opensource / au

A C++14-compatible physical units library with no dependencies and a single-file delivery option. Emphasis on safety, accessibility, performance, and developer experience.
Apache License 2.0
329 stars 21 forks source link

Solve most `[UNLABELED_UNIT]` instances by generating magnitude labels #85

Open chiphogg opened 1 year ago

chiphogg commented 1 year ago

Right now, the unit resulting from scaling a unit by a magnitude gets the default label, [UNLABELED_UNIT]. It's important that it not have the same label as the unscaled unit. Still, we can do much better if we design magnitude labels: automatic string constants that represent magnitudes.

Possible examples:

To solve this, we would need to come up with a collection of canonical examples we can use as acceptance tests, and work out the general rules. We also need to figure out how to handle things like parentheses, powers, and roots.

chiphogg commented 3 weeks ago

Based on discussion on the discord DMs for the C++ standard units library, I think a scaled unit should have the format [M U], where M is the magnitude label, and U is the label for the unscaled unit. That is: the new label should be fully enclosed in square brackets.