Skip to content

Commit 48815b5

Browse files
committed
expand forward iterator fulfilment note
1 parent ea7a13a commit 48815b5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

doc/collections_as_container.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ In the following tables a convention from `Collection` is used: `iterator` stand
9494
| `std::contiguous_iterator` | ❌ no | ❌ no |
9595

9696
:::{note}
97-
The collections' iterators fulfil the `std::forward_iterator` except that the pointers obtained with `->` remain valid only as long as the iterator is valid instead of as long as the range remain valid. In practice this means a `ptr` obtained with `auto* ptr = it.operator->();` is valid only as long as `it` is valid.
98-
The values obtained immediately through `->` (for instance `auto& e = it->energy();`) behaves as expected for `std::forward_iterator` as their validity is tied to the validity of a collection.
97+
The collections' iterators fulfil the `std::forward_iterator` except that the pointers obtained with `->` remain valid only as long as the iterator itself is valid instead of as long as the range remains valid. In practice, this means a `ptr` obtained with `auto* ptr = it.operator->();` is valid only as long as `it` is valid.
98+
The values obtained immediately through `->` (for instance, `auto& e = it->energy();`) behave as expected for `std::forward_iterator`, as their validity is tied to the collection's validity.
99+
Despite the exception, the collection iterators are made to still report themselves as fulfilling the forward iterator requirements since the problematic usage (`auto* ptr = it.operator->();`) is rare in normal scenarios.
99100
:::
100101

101102
### LegacyIterator

0 commit comments

Comments
 (0)