Skip to content

Commit d40449a

Browse files
jensmaurertkoeppe
authored andcommitted
[range.approximately.sized] Move to before [range.sized]
This is an unfortunate application of P2846R6.
1 parent ddb98da commit d40449a

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

source/ranges.tex

+40-40
Original file line numberDiff line numberDiff line change
@@ -1146,46 +1146,6 @@
11461146
its type is integer-like.
11471147
\end{note}
11481148

1149-
\rSec2[range.approximately.sized]{Approximately sized ranges}
1150-
1151-
\pnum
1152-
The \libconcept{approximately_sized_range} concept refines \libconcept{range}
1153-
with the requirement that
1154-
an approximation of the number of elements in the range
1155-
can be determined in amortized constant time using \tcode{ranges::reserve_hint}.
1156-
1157-
\begin{itemdecl}
1158-
template<class T>
1159-
concept @\deflibconcept{approximately_sized_range}@ =
1160-
@\libconcept{range}@<T> && requires(T& t) { ranges::reserve_hint(t); };
1161-
\end{itemdecl}
1162-
1163-
\begin{itemdescr}
1164-
\pnum
1165-
Given an lvalue \tcode{t} of type \tcode{remove_reference_t<T>},
1166-
\tcode{T} models \libconcept{approximately_sized_range} only if
1167-
\begin{itemize}
1168-
\item
1169-
\tcode{ranges::reserve_hint(t)} is amortized \bigoh{1},
1170-
does not modify \tcode{t}, and
1171-
has a value that
1172-
is not negative and is representable in \tcode{range_difference_t<T>}, and
1173-
\item
1174-
if \tcode{iterator_t<T>} models \libconcept{forward_iterator},
1175-
\tcode{ranges::reserve_hint(t)} is well-defined
1176-
regardless of the evaluation of \tcode{ranges::begin(t)}.
1177-
\begin{note}
1178-
\tcode{ranges::reserve_hint(t)} is otherwise not required to be well-defined
1179-
after evaluating \tcode{ranges::\linebreak begin(t)}.
1180-
For example,
1181-
it is possible for \tcode{ranges::reserve_hint(t)} to be well-defined for
1182-
an \libconceptx{approximate\-ly_sized_range}{approximately_sized_range} whose
1183-
iterator type does not model \libconcept{forward_iterator}
1184-
only if evaluated before the first call to \tcode{ranges::begin(t)}.
1185-
\end{note}
1186-
\end{itemize}
1187-
\end{itemdescr}
1188-
11891149
\rSec2[range.prim.empty]{\tcode{ranges::empty}}
11901150
\indexlibraryglobal{empty}%
11911151

@@ -1463,6 +1423,46 @@
14631423
\end{example}
14641424
\end{itemdescr}
14651425

1426+
\rSec2[range.approximately.sized]{Approximately sized ranges}
1427+
1428+
\pnum
1429+
The \libconcept{approximately_sized_range} concept refines \libconcept{range}
1430+
with the requirement that
1431+
an approximation of the number of elements in the range
1432+
can be determined in amortized constant time using \tcode{ranges::reserve_hint}.
1433+
1434+
\begin{itemdecl}
1435+
template<class T>
1436+
concept @\deflibconcept{approximately_sized_range}@ =
1437+
@\libconcept{range}@<T> && requires(T& t) { ranges::reserve_hint(t); };
1438+
\end{itemdecl}
1439+
1440+
\begin{itemdescr}
1441+
\pnum
1442+
Given an lvalue \tcode{t} of type \tcode{remove_reference_t<T>},
1443+
\tcode{T} models \libconcept{approximately_sized_range} only if
1444+
\begin{itemize}
1445+
\item
1446+
\tcode{ranges::reserve_hint(t)} is amortized \bigoh{1},
1447+
does not modify \tcode{t}, and
1448+
has a value that
1449+
is not negative and is representable in \tcode{range_difference_t<T>}, and
1450+
\item
1451+
if \tcode{iterator_t<T>} models \libconcept{forward_iterator},
1452+
\tcode{ranges::reserve_hint(t)} is well-defined
1453+
regardless of the evaluation of \tcode{ranges::begin(t)}.
1454+
\begin{note}
1455+
\tcode{ranges::reserve_hint(t)} is otherwise not required to be well-defined
1456+
after evaluating \tcode{ranges::\linebreak begin(t)}.
1457+
For example,
1458+
it is possible for \tcode{ranges::reserve_hint(t)} to be well-defined for
1459+
an \libconceptx{approximate\-ly_sized_range}{approximately_sized_range} whose
1460+
iterator type does not model \libconcept{forward_iterator}
1461+
only if evaluated before the first call to \tcode{ranges::begin(t)}.
1462+
\end{note}
1463+
\end{itemize}
1464+
\end{itemdescr}
1465+
14661466
\rSec2[range.sized]{Sized ranges}
14671467

14681468
\pnum

0 commit comments

Comments
 (0)