Skip to content

Commit 758b012

Browse files
jensmaurertkoeppe
authored andcommitted
P2408R5 Ranges iterators as inputs to non-Ranges algorithms
1 parent c8dbc86 commit 758b012

File tree

3 files changed

+34
-30
lines changed

3 files changed

+34
-30
lines changed

source/algorithms.tex

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
Throughout this Clause, where the template parameters are not constrained,
7070
the names of template parameters are used to express type requirements.
7171
\begin{itemize}
72+
\item
73+
If an algorithm's \Fundescx{Effects} element specifies
74+
that a value pointed to by any iterator passed as an argument is modified,
75+
then the type of that argument shall meet
76+
the requirements of a mutable iterator\iref{iterator.requirements}.
7277
\item
7378
If an algorithm's template parameter is named
7479
\tcode{InputIterator},
@@ -86,16 +91,18 @@
8691
\item
8792
If an algorithm's template parameter is named
8893
\tcode{ForwardIterator},
89-
\tcode{ForwardIterator1}, or
90-
\tcode{Forward\-Iterator2},
94+
\tcode{ForwardIterator1},
95+
\tcode{ForwardItera\-tor2}, or
96+
\tcode{NoThrowForwardIterator},
9197
the template argument shall meet the
92-
\oldconcept{ForwardIterator} requirements\iref{forward.iterators}.
98+
\oldconcept{ForwardIterator} requirements\iref{forward.iterators}
99+
if it is required to be a mutable iterator, or
100+
model \libconcept{forward_iterator}\iref{iterator.concept.forward} otherwise.
93101
\item
94102
If an algorithm's template parameter is named
95103
\tcode{NoThrowForwardIterator},
96-
the template argument shall meet the
97-
\oldconcept{ForwardIterator} requirements\iref{forward.iterators}, and
98-
is required to have the property that no exceptions are thrown
104+
the template argument
105+
is also required to have the property that no exceptions are thrown
99106
from increment, assignment, or comparison of, or
100107
indirection through, valid iterators.
101108
\item
@@ -104,28 +111,23 @@
104111
\tcode{Bidirectional\-Iterator1}, or
105112
\tcode{BidirectionalIterator2},
106113
the template argument shall meet the
107-
\oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators}.
114+
\oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators}
115+
if it is required to be a mutable iterator, or model
116+
\libconcept{bidirectional_iterator}\iref{iterator.concept.bidir} otherwise.
108117
\item
109118
If an algorithm's template parameter is named
110119
\tcode{RandomAccessIterator},
111120
\tcode{Random\-AccessIterator1}, or
112121
\tcode{RandomAccessIterator2},
113122
the template argument shall meet the
114-
\oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators}.
123+
\oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators}
124+
if it is required to be a mutable iterator, or model
125+
\libconcept{random_access_iterator}\iref{iterator.concept.random.access} otherwise.
115126
\end{itemize}
116-
117-
\pnum
118-
If an algorithm's \effects element specifies
119-
that a value pointed to by any iterator passed as an argument is modified,
120-
then that algorithm has an additional type requirement:
121-
The type of that argument shall meet
122-
the requirements of a mutable iterator\iref{iterator.requirements}.
123127
\begin{note}
124-
This requirement does not affect arguments that are named
125-
\tcode{OutputIterator}, \tcode{OutputIterator1}, or \tcode{OutputIterator2},
126-
because output iterators must always be mutable, nor
127-
does it affect arguments that are constrained,
128-
for which mutability requirements are expressed explicitly.
128+
These requirements do not affect iterator arguments that are constrained,
129+
for which iterator category and mutability requirements
130+
are expressed explicitly.
129131
\end{note}
130132

131133
\pnum
@@ -6033,8 +6035,8 @@
60336035
\item
60346036
For the overloads with no \tcode{ExecutionPolicy},
60356037
let \tcode{T} be the value type of \tcode{InputIterator}.
6036-
If \tcode{InputIterator} meets
6037-
the \oldconcept{ForwardIterator} requirements,
6038+
If \tcode{InputIterator} models
6039+
\libconcept{forward_iterator}\iref{iterator.concept.forward},
60386040
then there are no additional requirements for \tcode{T}.
60396041
Otherwise, if \tcode{OutputIterator} meets
60406042
the \oldconcept{ForwardIterator} requirements and
@@ -6339,8 +6341,8 @@
63396341
\item
63406342
\tcode{SampleIterator} meets
63416343
the \oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators}
6342-
unless \tcode{Pop\-ulat\-ion\-Iter\-ator} meets
6343-
the \oldconcept{ForwardIterator} requirements\iref{forward.iterators}.
6344+
unless \tcode{Pop\-ulat\-ion\-Iter\-ator}
6345+
models \libconcept{forward_iterator}\iref{iterator.concept.forward}.
63446346
\item
63456347
\tcode{remove_reference_t<UniformRandomBitGenerator>} meets
63466348
the requirements of a uniform random bit generator type\iref{rand.req.urng}.
@@ -6369,8 +6371,8 @@
63696371
\begin{itemize}
63706372
\item
63716373
For the overload in namespace \tcode{std},
6372-
stable if and only if \tcode{PopulationIterator} meets
6373-
the \oldconcept{For\-wardIterator} requirements.
6374+
stable if and only if \tcode{PopulationIterator}
6375+
models \libconcept{forward_iterator}.
63746376
For the first overload in namespace \tcode{ranges},
63756377
stable if and only if \tcode{I} models \libconcept{forward_iterator}.
63766378
\item

source/regex.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,8 +2691,8 @@
26912691
\begin{itemdescr}
26922692
\pnum
26932693
\expects
2694-
\tcode{BidirectionalIterator} meets the
2695-
\oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators}.
2694+
\tcode{BidirectionalIterator} models
2695+
\libconcept{bidirectional_iterator}\iref{iterator.concept.bidir}.
26962696

26972697
\pnum
26982698
\effects
@@ -2881,8 +2881,8 @@
28812881
\begin{itemdescr}
28822882
\pnum
28832883
\expects
2884-
\tcode{BidirectionalIterator} meets the
2885-
\oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators}.
2884+
\tcode{BidirectionalIterator} models
2885+
\libconcept{bidirectional_iterator}\iref{iterator.concept.bidir}.
28862886

28872887
\pnum
28882888
\effects

source/support.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@
553553
\begin{codeblock}
554554
// all freestanding
555555
#define @\defnlibxname{cpp_lib_addressof_constexpr}@ 201603L // also in \libheader{memory}
556+
#define @\defnlibxname{cpp_lib_algorithm_iterator_requirements}@ 202207L
557+
// also in \libheader{algorithm}, \libheader{numeric}, \libheader{memory}
556558
#define @\defnlibxname{cpp_lib_allocate_at_least}@ 202106L // also in \libheader{memory}
557559
#define @\defnlibxname{cpp_lib_allocator_traits_is_always_equal}@ 201411L
558560
// also in \libheader{memory}, \libheader{scoped_allocator}, \libheader{string}, \libheader{deque}, \libheader{forward_list}, \libheader{list}, \libheader{vector},

0 commit comments

Comments
 (0)