Skip to content

Commit 4fe0325

Browse files
eisenwavetkoeppe
authored andcommitted
P3709R2 Reconsider parallel ranges::rotate_copy and ranges::reverse_copy
1 parent 91a3811 commit 4fe0325

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

source/algorithms.tex

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,9 @@
26082608

26092609
namespace ranges {
26102610
template<class I, class O>
2611-
using reverse_copy_result = in_out_result<I, O>;
2611+
using @\libglobal{reverse_copy_result}@ = in_out_result<I, O>;
2612+
template<class I, class O>
2613+
using @\libglobal{reverse_copy_truncated_result}@ = in_in_out_result<I, I, O>;
26122614

26132615
template<@\libconcept{bidirectional_iterator}@ I, @\libconcept{sentinel_for}@<I> S, @\libconcept{weakly_incrementable}@ O>
26142616
requires @\libconcept{indirectly_copyable}@<I, O>
@@ -2622,12 +2624,12 @@
26222624
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
26232625
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
26242626
requires @\libconcept{indirectly_copyable}@<I, O>
2625-
reverse_copy_result<I, O>
2627+
reverse_copy_truncated_result<I, O>
26262628
reverse_copy(Ep&& exec, I first, S last, O result,
26272629
OutS result_last); // freestanding-deleted
26282630
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
26292631
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
2630-
reverse_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
2632+
reverse_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
26312633
reverse_copy(Ep&& exec, R&& r, OutR&& result_r); // freestanding-deleted
26322634
}
26332635

@@ -2671,7 +2673,9 @@
26712673

26722674
namespace ranges {
26732675
template<class I, class O>
2674-
using rotate_copy_result = in_out_result<I, O>;
2676+
using @\libglobal{rotate_copy_result}@ = in_out_result<I, O>;
2677+
template<class I, class O>
2678+
using @\libglobal{rotate_copy_truncated_result}@ = in_in_out_result<I, I, O>;
26752679

26762680
template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, @\libconcept{weakly_incrementable}@ O>
26772681
requires @\libconcept{indirectly_copyable}@<I, O>
@@ -2686,12 +2690,12 @@
26862690
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
26872691
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
26882692
requires @\libconcept{indirectly_copyable}@<I, O>
2689-
ranges::rotate_copy_result<I, O>
2693+
ranges::rotate_copy_truncated_result<I, O>
26902694
ranges::rotate_copy(Ep&& exec, I first, I middle, S last, O result,
26912695
OutS result_last); // freestanding-deleted
26922696
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
26932697
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
2694-
ranges::rotate_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
2698+
ranges::rotate_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
26952699
ranges::rotate_copy(Ep&& exec, R&& r, iterator_t<R> middle,
26962700
OutR&& result_r); // freestanding-deleted
26972701
// FIXME: once ranges:: is removed, reflow the previous two lines into one
@@ -8163,12 +8167,12 @@
81638167
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
81648168
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
81658169
requires @\libconcept{indirectly_copyable}@<I, O>
8166-
ranges::reverse_copy_result<I, O>
8170+
ranges::reverse_copy_truncated_result<I, O>
81678171
ranges::reverse_copy(Ep&& exec, I first, S last, O result,
81688172
OutS result_last);
81698173
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
81708174
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
8171-
ranges::reverse_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
8175+
ranges::reverse_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
81728176
ranges::reverse_copy(Ep&& exec, R&& r, OutR&& result_r);
81738177
\end{itemdecl}
81748178

@@ -8194,16 +8198,7 @@
81948198

81958199
\pnum
81968200
\returns
8197-
\tcode{\{\exposid{NEW_FIRST}, result + $N$\}}.
8198-
\begin{note}
8199-
While the return type for the parallel and non-parallel algorithm overloads
8200-
in the namespace \tcode{ranges} is the same,
8201-
the semantics is different
8202-
because for the parallel range algorithm overloads
8203-
%FIXME: Comma.
8204-
\tcode{result_last - result} can be insufficient
8205-
to copy all data from the input.
8206-
\end{note}
8201+
\tcode{\{last, \exposid{NEW_FIRST}, result + $N$\}}.
82078202

82088203
\pnum
82098204
\complexity
@@ -8346,7 +8341,7 @@
83468341
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
83478342
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
83488343
requires @\libconcept{indirectly_copyable}@<I, O>
8349-
ranges::rotate_copy_result<I, O>
8344+
ranges::rotate_copy_truncated_result<I, O>
83508345
ranges::rotate_copy(Ep&& exec, I first, I middle, S last, O result, OutS result_last);
83518346
\end{itemdecl}
83528347

@@ -8374,16 +8369,14 @@
83748369

83758370
\pnum
83768371
\returns
8377-
\tcode{\{first + ($N$ + (middle - first)) \% $M$, result + $N$\}}.
8378-
\begin{note}
8379-
While the return type for the parallel and non-parallel algorithm overloads
8380-
in the namespace \tcode{ranges} is the same,
8381-
the semantics is different
8382-
because for the parallel range algorithm overloads
8383-
%FIXME: Comma.
8384-
\tcode{result_last - result} can be insufficient
8385-
to copy all data from the input.
8386-
\end{note}
8372+
\begin{itemize}
8373+
\item
8374+
\tcode{\{middle + $N$, first, result + $N$\}}
8375+
if $N$ is less than \tcode{last - middle}.
8376+
\item
8377+
Otherwise,
8378+
\tcode{\{last, first + ($N$ + (middle - first)) \% $M$, result + $N$\}}.
8379+
\end{itemize}
83878380

83888381
\pnum
83898382
\complexity
@@ -8409,7 +8402,7 @@
84098402
\begin{itemdecl}
84108403
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
84118404
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
8412-
ranges::rotate_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
8405+
ranges::rotate_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
84138406
ranges::rotate_copy(Ep&& exec, R&& r, iterator_t<R> middle, OutR&& result_r);
84148407
\end{itemdecl}
84158408

0 commit comments

Comments
 (0)