diff --git a/au/code/au/quantity.hh b/au/code/au/quantity.hh index ace81ae3..62f592ef 100644 --- a/au/code/au/quantity.hh +++ b/au/code/au/quantity.hh @@ -403,7 +403,7 @@ class Quantity { constexpr Quantity(Rep value) : value_{value} {} - Rep value_{0}; + Rep value_{}; }; // Force integer division beteween two integer Quantities, in a callsite-obvious way. diff --git a/docs/reference/quantity.md b/docs/reference/quantity.md index be6f1d56..9a517bee 100644 --- a/docs/reference/quantity.md +++ b/docs/reference/quantity.md @@ -133,11 +133,17 @@ class Quantity { }; ``` -A default-constructed `Quantity` is initialized to some value, which helps avoid certain kinds of -memory safety bugs. However, **the value is contractually unspecified**. You can of course look up -that value by reading the source code, but we may change it in the future, and **we would not -consider this to be a breaking change**. The only valid operation on a default-constructed -`Quantity` is to assign to it later on. +A default-constructed `Quantity` is always initialized (which helps avoid certain kinds of memory +safety bugs). It will contain a default-constructed instance of the rep type. + +!!! warning + Avoid relying on the _specific value_ of a default-constructed `Quantity`, because it poorly + communicates intent. The only logically valid operation on a default-constructed `Quantity` is + to assign to it later on. + + The default value for many rep types, including all fundamental arithmetic types, is `0`. + Instead of relying on this behaviour, initialize your `Quantity` with [`au::ZERO`](./zero.md) to + better communicate your intent. ### Constructing from corresponding quantity