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

P3349R1 Converting contiguous iterators to pointers #7693

Merged
merged 1 commit into from
Mar 15, 2025
Merged
Changes from all 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
18 changes: 18 additions & 0 deletions source/iterators.tex
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,24 @@
The result of the application of library functions
to invalid ranges is undefined.

\pnum
For an iterator \tcode{i} of a type that
models \libconcept{contiguous_iterator}\iref{iterator.concept.contiguous},
library functions are permitted
to replace \range{i}{s} with
\range{to_address(i)}{to_address(i + ranges::distance(i, s))}, and
to replace \countedrange{i}{n} with \range{to_address(i)}{to_address(i + n)}.
\begin{note}
This means a program cannot rely on any side effects of
dereferencing a contiguous iterator \tcode{i},
because library functions might operate on
pointers obtained by \tcode{to_address(i)}
instead of operating on \tcode{i}.
Similarly, a program cannot rely on any side effects of
individual increments on a contiguous iterator \tcode{i},
because library functions might advance \tcode{i} only once.
\end{note}

\pnum
All the categories of iterators require only those functions that are realizable for a given category in
constant time (amortized).
Expand Down