From fed6a50a60b06676a625bf3afe07bfeee493fe05 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 17 Feb 2025 20:33:19 -0800 Subject: [PATCH] P3349R1 Converting contiguous iterators to pointers --- source/iterators.tex | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/iterators.tex b/source/iterators.tex index 7c7e7b92f3..4cf779c363 100644 --- a/source/iterators.tex +++ b/source/iterators.tex @@ -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).