Skip to content

P3709R2 Reconsider parallel ranges::rotate_copy and ranges::reverse_copy #8048

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

Merged
merged 1 commit into from
Jul 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
51 changes: 23 additions & 28 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,9 @@

namespace ranges {
template<class I, class O>
using reverse_copy_result = in_out_result<I, O>;
using @\libglobal{reverse_copy_result}@ = in_out_result<I, O>;
template<class I, class O>
using @\libglobal{reverse_copy_truncated_result}@ = in_in_out_result<I, I, O>;

template<@\libconcept{bidirectional_iterator}@ I, @\libconcept{sentinel_for}@<I> S, @\libconcept{weakly_incrementable}@ O>
requires @\libconcept{indirectly_copyable}@<I, O>
Expand All @@ -2613,12 +2615,12 @@
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
requires @\libconcept{indirectly_copyable}@<I, O>
reverse_copy_result<I, O>
reverse_copy_truncated_result<I, O>
reverse_copy(Ep&& exec, I first, S last, O result,
OutS result_last); // freestanding-deleted
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
reverse_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
reverse_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
reverse_copy(Ep&& exec, R&& r, OutR&& result_r); // freestanding-deleted
}

Expand Down Expand Up @@ -2662,7 +2664,9 @@

namespace ranges {
template<class I, class O>
using rotate_copy_result = in_out_result<I, O>;
using @\libglobal{rotate_copy_result}@ = in_out_result<I, O>;
template<class I, class O>
using @\libglobal{rotate_copy_truncated_result}@ = in_in_out_result<I, I, O>;

template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, @\libconcept{weakly_incrementable}@ O>
requires @\libconcept{indirectly_copyable}@<I, O>
Expand All @@ -2676,12 +2680,12 @@
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
requires @\libconcept{indirectly_copyable}@<I, O>
rotate_copy_result<I, O>
rotate_copy_truncated_result<I, O>
rotate_copy(Ep&& exec, I first, I middle, S last, O result, // freestanding-deleted
OutS result_last);
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
rotate_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
rotate_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
rotate_copy(Ep&& exec, R&& r, iterator_t<R> middle, // freestanding-deleted
OutR&& result_r);
}
Expand Down Expand Up @@ -8140,12 +8144,12 @@
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
requires @\libconcept{indirectly_copyable}@<I, O>
ranges::reverse_copy_result<I, O>
ranges::reverse_copy_truncated_result<I, O>
ranges::reverse_copy(Ep&& exec, I first, S last, O result,
OutS result_last);
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
ranges::reverse_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
ranges::reverse_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
ranges::reverse_copy(Ep&& exec, R&& r, OutR&& result_r);
\end{itemdecl}

Expand All @@ -8169,15 +8173,7 @@

\pnum
\returns
\tcode{\{\exposid{NEW_FIRST}, result + $N$\}}.
\begin{note}
While the return type for the parallel and non-parallel algorithm overloads
in the namespace \tcode{ranges} is the same,
the semantics is different
because for the parallel range algorithm overloads
\tcode{result_last - result} can be insufficient
to copy all data from the input.
\end{note}
\tcode{\{last, \exposid{NEW_FIRST}, result + $N$\}}.

\pnum
\complexity
Expand Down Expand Up @@ -8320,7 +8316,7 @@
template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@<I> S,
@\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@<O> OutS>
requires @\libconcept{indirectly_copyable}@<I, O>
ranges::rotate_copy_result<I, O>
ranges::rotate_copy_truncated_result<I, O>
ranges::rotate_copy(Ep&& exec, I first, I middle, S last, O result, OutS result_last);
\end{itemdecl}

Expand All @@ -8346,15 +8342,14 @@

\pnum
\returns
\tcode{\{first + ($N$ + (middle - first)) \% $M$, result + $N$\}}.
\begin{note}
While the return type for the parallel and non-parallel algorithm overloads
in the namespace \tcode{ranges} is the same,
the semantics is different
because for the parallel range algorithm overloads
\tcode{result_last - result} can be insufficient
to copy all data from the input.
\end{note}
\begin{itemize}
\item
\tcode{\{middle + $N$, first, result + $N$\}}
if $N$ is less than \tcode{last - middle}.
\item
Otherwise,
\tcode{\{last, first + ($N$ + (middle - first)) \% $M$, result + $N$\}}.
\end{itemize}

\pnum
\complexity
Expand All @@ -8380,7 +8375,7 @@
\begin{itemdecl}
template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR>
requires @\libconcept{indirectly_copyable}@<iterator_t<R>, iterator_t<OutR>>
ranges::rotate_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
ranges::rotate_copy_truncated_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR>>
ranges::rotate_copy(Ep&& exec, R&& r, iterator_t<R> middle, OutR&& result_r);
\end{itemdecl}

Expand Down