Skip to content

Commit e7f4bea

Browse files
committed
Add usage notes to the docs for ..< and ..=
1 parent a7dd9ec commit e7f4bea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/cpp2/expressions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ For more examples, see also the examples in the previous two sections on `is` an
245245
246246
## <a id="ranges"></a> `..<` and `..=` — range operators
247247
248-
`..<` and `..=` designate a range of things. Use `begin ..< end` for a half-open range (that does not include `end`) and `first ..= last` for a closed range (that does include `last`). These operators work for any type that supports `++`; they start with the first value, and use `++` to increment until they reach the last value (which is included by `..=`, and not included by `..<`).
248+
`..<` and `..=` designate a range of things. Use `begin ..< end` for a half-open range (that does not include `end`) and `first ..= last` for a closed range (that does include `last`, and `last` must be a valid value and must be valid to increment once). These operators work for any type that supports `++`; they start with the `first` value, and use `++` to increment until they reach the `last` value (which is included by `..=`, and not included by `..<`).
249+
250+
> Note: For all numeric ranges, `last`'s value must be reachable by incrementing `first` a finite number of times. For `..=` closed numeric ranges, `last` must not be `std::numeric_limits<size_t>::max()` or `std::numeric_limits<ptrdiff_t>::max()`.
249251
250252
For example:
251253

0 commit comments

Comments
 (0)