Skip to content
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

Finish writing QuantityPoint reference #152

Merged
merged 6 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/discussion/idioms/unit-slots.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ they have two advantages that make them easier to read:
2. You can use grammatically correct names, such as `meters / squared(second)` (note: `second` is
singular), rather than `Meters{} / squared(Seconds{})`.

#### Notes for `QuantityPoint`

`QuantityPoint` doesn't use quantity makers: it uses quantity _point_ makers. For example, instead
of the quantity maker `meters`, it uses the quantity point maker `meters_pt`.

The implications are straightforward. If you have a `QuantityPoint` instead of a `Quantity`, then
use the quantity _point_ maker instead of the _quantity_ maker. The library will enforce this
automatically: for example, you can't pass `meters` to a `QuantityPoint`'s unit slot, and you can't
pass `meters_pt` to a `Quantity`'s unit slot.

## Examples: rounding to RPM

Let's look at some examples, using this quantity variable:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/quantity.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ slots](../discussion/idioms/unit-slots.md) discussion for valid choices for `uni
`int`.

The above example used the quantity maker, `inches`. One could also use an instance of the unit
type `Inches`, writing `length.as(Inches{})`. The former is generally preferable; the latter is
type `Inches`, writing `length.in(Inches{})`. The former is generally preferable; the latter is
mainly useful in generic code where the unit type may be all you have.

**Without** a template argument, `.in(unit)` obeys the same safety checks as for the [implicit
Expand Down
Loading