Skip to content

Commit 535393e

Browse files
authored
Merge 2025-02 LWG Motion 5
P3349R1 Converting contiguous iterators to pointers
2 parents 52b26f5 + fed6a50 commit 535393e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

source/iterators.tex

+18
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,24 @@
692692
The result of the application of library functions
693693
to invalid ranges is undefined.
694694

695+
\pnum
696+
For an iterator \tcode{i} of a type that
697+
models \libconcept{contiguous_iterator}\iref{iterator.concept.contiguous},
698+
library functions are permitted
699+
to replace \range{i}{s} with
700+
\range{to_address(i)}{to_address(i + ranges::distance(i, s))}, and
701+
to replace \countedrange{i}{n} with \range{to_address(i)}{to_address(i + n)}.
702+
\begin{note}
703+
This means a program cannot rely on any side effects of
704+
dereferencing a contiguous iterator \tcode{i},
705+
because library functions might operate on
706+
pointers obtained by \tcode{to_address(i)}
707+
instead of operating on \tcode{i}.
708+
Similarly, a program cannot rely on any side effects of
709+
individual increments on a contiguous iterator \tcode{i},
710+
because library functions might advance \tcode{i} only once.
711+
\end{note}
712+
695713
\pnum
696714
All the categories of iterators require only those functions that are realizable for a given category in
697715
constant time (amortized).

0 commit comments

Comments
 (0)