diff --git a/source/algorithms.tex b/source/algorithms.tex index 3790bb78bf..79bdd66a14 100644 --- a/source/algorithms.tex +++ b/source/algorithms.tex @@ -231,6 +231,15 @@ for (auto tmp = b; tmp != a; ++tmp) --n; return n; \end{codeblock} +For each iterator \tcode{i} and sentinel \tcode{s} +produced from a range \tcode{r}, +the semantics of \tcode{s - i} has the same type, value, and value category +as \tcode{ranges::distance(i, s)}. +\begin{note} +The implementation can use \tcode{ranges::distance(r)} +when that produces the same value as \tcode{ranges::\-distance(i, s)}. +This can be more efficient for sized ranges. +\end{note} \pnum In the description of the algorithms, @@ -249,10 +258,25 @@ \pnum Overloads of algorithms that take \libconcept{range} arguments\iref{range.range} -behave as if they are implemented by calling \tcode{ranges::begin} and -\tcode{ranges::end} on the \libconcept{range}(s) and +behave as if they are implemented by dispatching to the overload in namespace \tcode{ranges} -that takes separate iterator and sentinel arguments. +that takes separate iterator and sentinel arguments, +where for each range argument \tcode{r} +\begin{itemize} +\item + a corresponding iterator argument is initialized with \tcode{ranges::begin(r)} and +\item + a corresponding sentinel argument is initialized with \tcode{ranges::end(r)}, + or \tcode{ranges::\-next(ranges::\-begin(r), ranges::\-end(r))} + if the type of \tcode{r} models \libconcept{forward_range} + %TODO: this may be a wording bug; + %computing the expression ranges::next in itself is always O(1) + %because it is merely designating some function object, + %so the complexity requirement is vacuously satisfied. + %We probably want to say \tcode{ranges::next(r)} here, + %which is the intent, of course. + and computing \tcode{ranges::next} meets the specified complexity requirements. +\end{itemize} \pnum The well-formedness and behavior of a call to an algorithm with @@ -272,23 +296,30 @@ \pnum A \defn{parallel algorithm} is a function template listed in this document -with a template parameter named \tcode{ExecutionPolicy}. +with a template parameter named \tcode{ExecutionPolicy} +or constrained by the following exposition-only concept: +\begin{codeblock} +template +concept @\defexposconcept{execution-policy}@ = // \expos + is_execution_policy_v>; +\end{codeblock} +Such a template parameter is termed an \defnadj{execution policy}{template parameter}. \pnum -Parallel algorithms access objects indirectly accessible via their arguments +A parallel algorithm accesses objects indirectly accessible via its arguments by invoking the following functions: \begin{itemize} \item - All operations of the categories of the iterators or \tcode{mdspan} types + All operations of the categories of the iterators, sentinels, or \tcode{mdspan} types that the algorithm is instantiated with. \item Operations on those sequence elements that are required by its specification. \item - User-provided function objects + User-provided invocable objects to be applied during the execution of the algorithm, if required by the specification. \item - Operations on those function objects required by the specification. + Operations on those invocable objects required by the specification. \begin{note} See~\ref{algorithms.requirements}. \end{note} @@ -344,7 +375,8 @@ \pnum Unless otherwise specified, -function objects passed into parallel algorithms as objects of type +invocable objects passed into parallel algorithms as objects of a type +denoted by a template parameter named \tcode{Predicate}, \tcode{BinaryPredicate}, \tcode{Compare}, @@ -352,8 +384,10 @@ \tcode{BinaryOperation}, \tcode{BinaryOperation1}, \tcode{BinaryOperation2}, -\tcode{BinaryDivideOp}, and -the operators used by the analogous overloads to these parallel algorithms +\tcode{BinaryDivideOp}, or +constrained by a concept that subsumes \libconcept{regular_invocable} +%TODO: Comma here. +and the operators used by the analogous overloads to these parallel algorithms that are formed by an invocation with the specified default predicate or operation (where applicable) shall not directly or indirectly modify objects via their arguments, @@ -565,31 +599,31 @@ \pnum During the execution of a parallel algorithm, if the invocation of an element access function exits via an uncaught exception, -the behavior is determined by the \tcode{ExecutionPolicy}. +the behavior is determined by the execution policy. \rSec2[algorithms.parallel.overloads]{\tcode{ExecutionPolicy} algorithm overloads} \pnum Parallel algorithms are algorithm overloads. Each parallel algorithm overload -has an additional template type parameter named \tcode{ExecutionPolicy}, -which is the first template parameter. -Additionally, each parallel algorithm overload -has an additional function parameter of type \tcode{ExecutionPolicy\&\&}, -which is the first function parameter. +has an additional function parameter $P$ of type \tcode{ExecutionPolicy\&\&}, +as the first function parameter, +where \tcode{T} is the execution policy template parameter. \begin{note} Not all algorithms have parallel algorithm overloads. \end{note} \pnum Unless otherwise specified, -the semantics of \tcode{ExecutionPolicy} algorithm overloads -are identical to their overloads without. +the semantics of calling a parallel algorithm overload are identical to +calling the corresponding algorithm overload without the parameter $P$, +using all but the first argument. \pnum Unless otherwise specified, -the complexity requirements of \tcode{ExecutionPolicy} algorithm overloads -are relaxed from the complexity requirements of the overloads without +the complexity requirements of a parallel algorithm overload +are relaxed from the complexity requirements of the corresponding overload +without the parameter $P$ as follows: when the guarantee says ``at most \placeholder{expr}'' or ``exactly \placeholder{expr}'' @@ -598,8 +632,10 @@ the complexity of the algorithm shall be \bigoh{\placeholder{expr}}. \pnum -Parallel algorithms shall not participate in overload resolution unless -\tcode{is_execution_policy_v>} is \tcode{true}. +A parallel algorithm +with a template parameter named \tcode{ExecutionPolicy} +shall not participate in overload resolution unless +that template parameter satisfies \exposconcept{execution-policy}. \rSec2[execpol]{Execution policies} @@ -821,6 +857,13 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool all_of(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool all_of(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool all_of(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } // \ref{alg.any.of}, any of @@ -837,6 +880,13 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool any_of(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool any_of(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool any_of(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } // \ref{alg.none.of}, none of @@ -853,6 +903,13 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool none_of(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool none_of(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool none_of(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } // \ref{alg.contains}, contains @@ -867,6 +924,17 @@ @\libconcept{indirect_binary_predicate}@, Proj>, const T*> constexpr bool contains(R&& r, const T& value, Proj proj = {}); + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + bool contains(Ep&& exec, I first, S last, const T& value, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + bool contains(Ep&& exec, R&& r, const T& value, Proj proj = {}); // freestanding-deleted + template<@\libconcept{forward_iterator}@ I1, @\libconcept{sentinel_for}@ S1, @\libconcept{forward_iterator}@ I2, @\libconcept{sentinel_for}@ S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> @@ -878,6 +946,18 @@ requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> constexpr bool contains_subrange(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool contains_subrange(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool contains_subrange(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, + Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.foreach}, for each @@ -899,6 +979,15 @@ @\libconcept{indirectly_unary_invocable}@, Proj>> Fun> constexpr for_each_result, Fun> for_each(R&& r, Fun f, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirectly_unary_invocable}@> Fun> + I for_each(Ep&& exec, I first, S last, Fun f, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirectly_unary_invocable}@, Proj>> Fun> + borrowed_iterator_t + for_each(Ep&& exec, R&& r, Fun f, Proj proj = {}); // freestanding-deleted } template @@ -915,6 +1004,11 @@ @\libconcept{indirectly_unary_invocable}@> Fun> constexpr for_each_n_result for_each_n(I first, iter_difference_t n, Fun f, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, class Proj = identity, + @\libconcept{indirectly_unary_invocable}@> Fun> + I for_each_n(Ep&& exec, I first, iter_difference_t n, Fun f, + Proj proj = {}); // freestanding-deleted } // \ref{alg.find}, find @@ -952,6 +1046,18 @@ projected, Proj>, const T*> constexpr borrowed_iterator_t find(R&& r, const T& value, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + I find(Ep&& exec, I first, S last, const T& value, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + borrowed_iterator_t + find(Ep&& exec, R&& r, const T& value, Proj proj = {}); // freestanding-deleted + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); @@ -959,6 +1065,15 @@ @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_iterator_t find_if(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + I find_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_iterator_t + find_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); @@ -966,6 +1081,14 @@ @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_iterator_t find_if_not(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + I find_if_not(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_iterator_t + find_if_not(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } // \ref{alg.find.last}, find last @@ -979,18 +1102,55 @@ requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> constexpr borrowed_subrange_t find_last(R&& r, const T& value, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + subrange + find_last(Ep&& exec, I first, S last, const T& value, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + borrowed_subrange_t + find_last(Ep&& exec, R&& r, const T& value, Proj proj = {}); // freestanding-deleted + template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr subrange find_last_if(I first, S last, Pred pred, Proj proj = {}); template<@\libconcept{forward_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_subrange_t find_last_if(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + subrange + find_last_if(Ep&& exec, I first, S last, Pred pred, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_subrange_t + find_last_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr subrange find_last_if_not(I first, S last, Pred pred, Proj proj = {}); template<@\libconcept{forward_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_subrange_t find_last_if_not(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@> Pred> + subrange + find_last_if_not(Ep&& exec, I first, S last, Pred pred, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_subrange_t + find_last_if_not(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } // \ref{alg.find.end}, find end @@ -1029,6 +1189,20 @@ constexpr borrowed_subrange_t find_end(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + subrange + find_end(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + borrowed_subrange_t + find_end(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.find.first.of}, find first @@ -1066,6 +1240,19 @@ constexpr borrowed_iterator_t find_first_of(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + I1 find_first_of(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + borrowed_iterator_t + find_first_of(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.adjacent.find}, adjacent find @@ -1097,6 +1284,18 @@ projected, Proj>> Pred = ranges::equal_to> constexpr borrowed_iterator_t adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_binary_predicate}@, + projected> Pred = ranges::equal_to> + I adjacent_find(Ep&& exec, I first, S last, Pred pred = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_binary_predicate}@, Proj>, + projected, Proj>> Pred = ranges::equal_to> + borrowed_iterator_t + adjacent_find(Ep&& exec, R&& r, Pred pred = {}, Proj proj = {}); // freestanding-deleted } // \ref{alg.count}, count @@ -1128,6 +1327,19 @@ projected, Proj>, const T*> constexpr range_difference_t count(R&& r, const T& value, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + iter_difference_t + count(Ep&& exec, I first, S last, const T& value, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + range_difference_t + count(Ep&& exec, R&& r, const T& value, Proj proj = {}); // freestanding-deleted + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr iter_difference_t @@ -1136,6 +1348,15 @@ @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr range_difference_t count_if(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + iter_difference_t + count_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + range_difference_t + count_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } // \ref{alg.mismatch}, mismatch @@ -1196,6 +1417,20 @@ constexpr mismatch_result, borrowed_iterator_t> mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + mismatch_result + mismatch(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + mismatch_result, borrowed_iterator_t> + mismatch(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.equal}, equal @@ -1244,6 +1479,18 @@ requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> constexpr bool equal(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool equal(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool equal(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.is.permutation}, is permutation @@ -1315,6 +1562,20 @@ constexpr borrowed_subrange_t search(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + subrange + search(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + borrowed_subrange_t + search(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } template search_n(R&& r, range_difference_t count, const T& value, Pred pred = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Pred = ranges::equal_to, class Proj = identity, + class T = projected_value_t> + requires @\libconcept{indirectly_comparable}@ + subrange + search_n(Ep&& exec, I first, S last, iter_difference_t count, + const T& value, Pred pred = {}, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Pred = ranges::equal_to, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirectly_comparable}@, const T*, Pred, Proj> + borrowed_subrange_t + search_n(Ep&& exec, R&& r, range_difference_t count, + const T& value, Pred pred = {}, Proj proj = {}); // freestanding-deleted } template @@ -1374,6 +1649,19 @@ constexpr bool starts_with(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool starts_with(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, + @\exposconcept{sized-random-access-range}@ R2, class Pred = ranges::equal_to, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool starts_with(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + // \ref{alg.ends.with}, ends with template<@\libconcept{input_iterator}@ I1, @\libconcept{sentinel_for}@ S1, @\libconcept{input_iterator}@ I2, @\libconcept{sentinel_for}@ S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> @@ -1390,6 +1678,19 @@ constexpr bool ends_with(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool ends_with(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, + @\exposconcept{sized-random-access-range}@ R2, class Pred = ranges::equal_to, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool ends_with(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + // \ref{alg.fold}, fold template class @\exposid{flipped}@ { // \expos @@ -1500,6 +1801,16 @@ requires @\libconcept{indirectly_copyable}@, O> constexpr copy_result, O> copy(R&& r, O result); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + copy_result + 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> + copy_result, borrowed_iterator_t> + copy(Ep&& exec, R&& r, OutR&& result_r); // freestanding-deleted } template @@ -1519,6 +1830,13 @@ requires @\libconcept{indirectly_copyable}@ constexpr copy_n_result copy_n(I first, iter_difference_t n, O result); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{random_access_iterator}@ O, + @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + copy_n_result + copy_n(Ep&& exec, I first, iter_difference_t n, O result, + OutS result_last); // freestanding-deleted } template @@ -1544,6 +1862,21 @@ requires @\libconcept{indirectly_copyable}@, O> constexpr copy_if_result, O> copy_if(R&& r, O result, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ + copy_if_result + copy_if(Ep&& exec, I first, S last, O result, OutS result_last, + Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> + copy_if_result, borrowed_iterator_t> + copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, + Proj proj = {}); // freestanding-deleted } template @@ -1587,6 +1920,16 @@ requires @\libconcept{indirectly_movable}@, O> constexpr move_result, O> move(R&& r, O result); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_movable}@ + move_result + move(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_movable}@, iterator_t> + move_result, borrowed_iterator_t> + move(Ep&& exec, R&& r, OutR&& result_r); // freestanding-deleted } template @@ -1629,6 +1972,16 @@ requires @\libconcept{indirectly_swappable}@, iterator_t> constexpr swap_ranges_result, borrowed_iterator_t> swap_ranges(R1&& r1, R2&& r2); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2> + requires @\libconcept{indirectly_swappable}@ + swap_ranges_result + swap_ranges(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2> + requires @\libconcept{indirectly_swappable}@, iterator_t> + swap_ranges_result, borrowed_iterator_t> + swap_ranges(Ep&& exec, R1&& r1, R2&& r2); // freestanding-deleted } template @@ -1674,6 +2027,20 @@ constexpr unary_transform_result, O> transform(R&& r, O result, F op, Proj proj = {}); + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + @\libconcept{copy_constructible}@ F, class Proj = identity> + requires @\libconcept{indirectly_writable}@>> + unary_transform_result + transform(Ep&& exec, I first1, S last1, O result, OutS result_last, + F op, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + @\libconcept{copy_constructible}@ F, class Proj = identity> + requires @\libconcept{indirectly_writable}@, + indirect_result_t, Proj>>> + unary_transform_result, borrowed_iterator_t> + transform(Ep&& exec, R&& r, OutR&& result_r, F op, Proj proj = {}); // freestanding-deleted + template using binary_transform_result = in_in_out_result; @@ -1692,6 +2059,27 @@ constexpr binary_transform_result, borrowed_iterator_t, O> transform(R1&& r1, R2&& r2, O result, F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + @\libconcept{copy_constructible}@ F, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_writable}@, + projected>> + binary_transform_result + transform(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + O result, OutS result_last, + F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, @\libconcept{copy_constructible}@ F, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_writable}@, + indirect_result_t, Proj1>, + projected, Proj2>>> + binary_transform_result, borrowed_iterator_t, + borrowed_iterator_t> + transform(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, + F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.replace}, replace @@ -1727,6 +2115,22 @@ projected, Proj>, const T1*> constexpr borrowed_iterator_t replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T1 = projected_value_t, class T2 = T1> + requires @\libconcept{indirectly_writable}@ && + @\libconcept{indirect_binary_predicate}@, const T1*> + I replace(Ep&& exec, I first, S last, + const T1& old_value, const T2& new_value, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T1 = projected_value_t, Proj>, class T2 = T1> + requires @\libconcept{indirectly_writable}@, const T2&> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T1*> + borrowed_iterator_t + replace(Ep&& exec, R&& r, const T1& old_value, const T2& new_value, + Proj proj = {}); // freestanding-deleted + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, class T = projected_value_t, @\libconcept{indirect_unary_predicate}@> Pred> @@ -1737,6 +2141,20 @@ requires @\libconcept{indirectly_writable}@, const T&> constexpr borrowed_iterator_t replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t, + @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_writable}@ + I replace_if(Ep&& exec, I first, S last, Pred pred, + const T& new_value, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_writable}@, const T&> + borrowed_iterator_t + replace_if(Ep&& exec, R&& r, Pred pred, const T& new_value, + Proj proj = {}); // freestanding-deleted } template @@ -1783,6 +2201,27 @@ replace_copy(R&& r, O result, const T1& old_value, const T2& new_value, Proj proj = {}); + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, + class T1 = projected_value_t, class T2 = iter_value_t> + requires @\libconcept{indirectly_copyable}@ && + @\libconcept{indirect_binary_predicate}@, const T1*> && + @\libconcept{indirectly_writable}@ + replace_copy_result + replace_copy(Ep&& exec, I first, S last, O result, OutS result_last, const T1& old_value, + const T2& new_value, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, class T1 = projected_value_t, Proj>, + class T2 = range_value_t> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T1*> && + @\libconcept{indirectly_writable}@, const T2&> + replace_copy_result, borrowed_iterator_t> + replace_copy(Ep&& exec, R&& r, OutR&& result_r, const T1& old_value, const T2& new_value, + Proj proj = {}); // freestanding-deleted + template using replace_copy_if_result = in_out_result; @@ -1798,6 +2237,22 @@ constexpr replace_copy_if_result, O> replace_copy_if(R&& r, O result, Pred pred, const T& new_value, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class T = iter_value_t, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ && @\libconcept{indirectly_writable}@ + replace_copy_if_result + replace_copy_if(Ep&& exec, I first, S last, O result, OutS result_last, + Pred pred, const T& new_value, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class T = range_value_t, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirectly_writable}@ + replace_copy_if_result, borrowed_iterator_t> + replace_copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, const T& new_value, + Proj proj = {}); // freestanding-deleted } // \ref{alg.fill}, fill @@ -1825,6 +2280,17 @@ template> requires @\libconcept{output_iterator}@ constexpr O fill_n(O first, iter_difference_t n, const T& value); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ S, + class T = iter_value_t> + requires @\libconcept{indirectly_writable}@ + O fill(Ep&& exec, O first, S last, const T& value); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class T = range_value_t> + requires @\libconcept{indirectly_writable}@, const T&> + borrowed_iterator_t fill(Ep&& exec, R&& r, const T& value); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, class T = iter_value_t> + requires @\libconcept{indirectly_writable}@ + O fill_n(Ep&& exec, O first, iter_difference_t n, const T& value); // freestanding-deleted } // \ref{alg.generate}, generate @@ -1841,7 +2307,7 @@ ForwardIterator generate_n(ExecutionPolicy&& exec, // freestanding-deleted, see \ref{algorithms.parallel.overloads} ForwardIterator first, Size n, Generator gen); - namespace ranges { + namespace ranges { // FIXME: missing gap between declaration bundles template<@\libconcept{input_or_output_iterator}@ O, @\libconcept{sentinel_for}@ S, @\libconcept{copy_constructible}@ F> requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@> constexpr O generate(O first, S last, F gen); @@ -1851,6 +2317,16 @@ template<@\libconcept{input_or_output_iterator}@ O, @\libconcept{copy_constructible}@ F> requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@> constexpr O generate_n(O first, iter_difference_t n, F gen); + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{copy_constructible}@ F> + requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@> + O generate(Ep&& exec, O first, S last, F gen); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\libconcept{copy_constructible}@ F> + requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@, invoke_result_t> + borrowed_iterator_t generate(Ep&& exec, R&& r, F gen); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, @\libconcept{copy_constructible}@ F> + requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@> + O generate_n(Ep&& exec, O first, iter_difference_t n, F gen); // freestanding-deleted } // \ref{alg.remove}, remove @@ -1882,6 +2358,20 @@ projected, Proj>, const T*> constexpr borrowed_subrange_t remove(R&& r, const T& value, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + subrange remove(Ep&& exec, I first, S last, const T& value, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires @\libconcept{permutable}@> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + borrowed_subrange_t + remove(Ep&& exec, R&& r, const T& value, Proj proj = {}); // freestanding-deleted + template<@\libconcept{permutable}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr subrange remove_if(I first, S last, Pred pred, Proj proj = {}); @@ -1890,6 +2380,16 @@ requires @\libconcept{permutable}@> constexpr borrowed_subrange_t remove_if(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + subrange + remove_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{permutable}@> + borrowed_subrange_t + remove_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } template, O> remove_copy(R&& r, O result, const T& value, Proj proj = {}); + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirectly_copyable}@ && + @\libconcept{indirect_binary_predicate}@, const T*> + remove_copy_result + remove_copy(Ep&& exec, I first, S last, O result, OutS result_last, const T& value, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, class T = projected_value_t, Proj>> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + remove_copy_result, borrowed_iterator_t> + remove_copy(Ep&& exec, R&& r, OutR&& result_r, const T& value, + Proj proj = {}); // freestanding-deleted + template using remove_copy_if_result = in_out_result; @@ -1945,6 +2462,21 @@ requires @\libconcept{indirectly_copyable}@, O> constexpr remove_copy_if_result, O> remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ + remove_copy_if_result + remove_copy_if(Ep&& exec, I first, S last, O result, OutS result_last, Pred pred, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> + remove_copy_if_result, borrowed_iterator_t> + remove_copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, + Proj proj = {}); // freestanding-deleted } // \ref{alg.unique}, unique @@ -1970,6 +2502,18 @@ requires @\libconcept{permutable}@> constexpr borrowed_subrange_t unique(R&& r, C comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_equivalence_relation}@> C = ranges::equal_to> + requires @\libconcept{permutable}@ + subrange unique(Ep&& exec, I first, S last, C comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_equivalence_relation}@, Proj>> C = ranges::equal_to> + requires @\libconcept{permutable}@> + borrowed_subrange_t + unique(Ep&& exec, R&& r, C comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -2012,6 +2556,21 @@ @\libconcept{indirectly_copyable_storable}@, O>) constexpr unique_copy_result, O> unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Proj = identity, + @\libconcept{indirect_equivalence_relation}@> C = ranges::equal_to> + requires @\libconcept{indirectly_copyable}@ + unique_copy_result + unique_copy(Ep&& exec, I first, S last, O result, OutS result_last, C comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, + @\libconcept{indirect_equivalence_relation}@, Proj>> C = ranges::equal_to> + requires @\libconcept{indirectly_copyable}@, iterator_t> + unique_copy_result, borrowed_iterator_t> + unique_copy(Ep&& exec, R&& r, OutR&& result_r, C comp = {}, + Proj proj = {}); // freestanding-deleted } // \ref{alg.reverse}, reverse @@ -2028,6 +2587,13 @@ template<@\libconcept{bidirectional_range}@ R> requires @\libconcept{permutable}@> constexpr borrowed_iterator_t reverse(R&& r); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + I reverse(Ep&& exec, I first, S last); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_iterator_t reverse(Ep&& exec, R&& r); // freestanding-deleted } template @@ -2042,7 +2608,9 @@ namespace ranges { template - using reverse_copy_result = in_out_result; + using @\libglobal{reverse_copy_result}@ = in_out_result; + template + using @\libglobal{reverse_copy_truncated_result}@ = in_in_out_result; template<@\libconcept{bidirectional_iterator}@ I, @\libconcept{sentinel_for}@ S, @\libconcept{weakly_incrementable}@ O> requires @\libconcept{indirectly_copyable}@ @@ -2052,6 +2620,17 @@ requires @\libconcept{indirectly_copyable}@, O> constexpr reverse_copy_result, O> reverse_copy(R&& r, O result); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + reverse_copy_truncated_result + 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> + reverse_copy_truncated_result, borrowed_iterator_t> + reverse_copy(Ep&& exec, R&& r, OutR&& result_r); // freestanding-deleted } // \ref{alg.rotate}, rotate @@ -2071,6 +2650,15 @@ template<@\libconcept{forward_range}@ R> requires @\libconcept{permutable}@> constexpr borrowed_subrange_t rotate(R&& r, iterator_t middle); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + subrange + rotate(Ep&& exec, I first, I middle, S last); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_subrange_t + rotate(Ep&& exec, R&& r, iterator_t middle); // freestanding-deleted } template @@ -2085,7 +2673,9 @@ namespace ranges { template - using rotate_copy_result = in_out_result; + using @\libglobal{rotate_copy_result}@ = in_out_result; + template + using @\libglobal{rotate_copy_truncated_result}@ = in_in_out_result; template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@ S, @\libconcept{weakly_incrementable}@ O> requires @\libconcept{indirectly_copyable}@ @@ -2095,6 +2685,20 @@ requires @\libconcept{indirectly_copyable}@, O> constexpr rotate_copy_result, O> rotate_copy(R&& r, iterator_t middle, O result); + + // FIXME: remove ranges:: namespace + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + ranges::rotate_copy_truncated_result + ranges::rotate_copy(Ep&& exec, I first, I middle, 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> + ranges::rotate_copy_truncated_result, borrowed_iterator_t> + ranges::rotate_copy(Ep&& exec, R&& r, iterator_t middle, + OutR&& result_r); // freestanding-deleted + // FIXME: once ranges:: is removed, reflow the previous two lines into one } // \ref{alg.random.sample}, sample @@ -2152,6 +2756,15 @@ template<@\libconcept{forward_range}@ R> requires @\libconcept{permutable}@> constexpr borrowed_subrange_t shift_left(R&& r, range_difference_t n); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + subrange + shift_left(Ep&& exec, I first, S last, iter_difference_t n); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_subrange_t + shift_left(Ep&& exec, R&& r, range_difference_t n); // freestanding-deleted } template @@ -2170,6 +2783,15 @@ template<@\libconcept{forward_range}@ R> requires @\libconcept{permutable}@> constexpr borrowed_subrange_t shift_right(R&& r, range_difference_t n); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + subrange + shift_right(Ep&& exec, I first, S last, iter_difference_t n); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_subrange_t + shift_right(Ep&& exec, R&& r, range_difference_t n); // freestanding-deleted } // \ref{alg.sorting}, sorting and related operations @@ -2197,6 +2819,16 @@ requires @\libconcept{sortable}@, Comp, Proj> constexpr borrowed_iterator_t sort(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I sort(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + sort(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -2221,6 +2853,17 @@ requires @\libconcept{sortable}@, Comp, Proj> constexpr borrowed_iterator_t stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // hosted + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I stable_sort(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + stable_sort(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -2249,6 +2892,18 @@ constexpr borrowed_iterator_t partial_sort(R&& r, iterator_t middle, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I partial_sort(Ep&& exec, I first, I middle, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + partial_sort(Ep&& exec, R&& r, iterator_t middle, Comp comp = {}, + Proj proj = {}); // freestanding-deleted } template @@ -2298,6 +2953,25 @@ constexpr partial_sort_copy_result, borrowed_iterator_t> partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_copyable}@ && @\libconcept{sortable}@ && + @\libconcept{indirect_strict_weak_order}@, projected> + partial_sort_copy_result + partial_sort_copy(Ep&& exec, I1 first, S1 last, I2 result_first, S2 result_last, + Comp comp = {}, Proj1 proj1 = {}, + Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{sortable}@, Comp, Proj2> && + @\libconcept{indirect_strict_weak_order}@, Proj1>, + projected, Proj2>> + partial_sort_copy_result, borrowed_iterator_t> + partial_sort_copy(Ep&& exec, R1&& r, R2&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } template @@ -2320,6 +2994,15 @@ template<@\libconcept{forward_range}@ R, class Proj = identity, @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr bool is_sorted(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + bool is_sorted(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + bool is_sorted(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -2347,6 +3030,16 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I is_sorted_until(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + is_sorted_until(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } // \ref{alg.nth.element}, Nth element @@ -2375,7 +3068,19 @@ requires @\libconcept{sortable}@, Comp, Proj> constexpr borrowed_iterator_t nth_element(R&& r, iterator_t nth, Comp comp = {}, Proj proj = {}); - } + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I nth_element(Ep&& exec, I first, I nth, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + nth_element(Ep&& exec, R&& r, iterator_t nth, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + } // \ref{alg.binary.search}, binary search template::value_type> @@ -2487,6 +3192,14 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool is_partitioned(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool is_partitioned(Ep&& exec, I first, S last, Pred pred, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool is_partitioned(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } template @@ -2509,6 +3222,17 @@ requires @\libconcept{permutable}@> constexpr borrowed_subrange_t partition(R&& r, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + subrange + // FIXME: LWG issue, I'm pretty sure there should be requires permutable here. + partition(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{permutable}@> + borrowed_subrange_t + partition(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } template @@ -2532,6 +3256,18 @@ requires @\libconcept{permutable}@> constexpr borrowed_subrange_t stable_partition(R&& r, Pred pred, // hosted Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{permutable}@ + subrange + stable_partition(Ep&& exec, I first, S last, Pred pred, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{permutable}@> + borrowed_subrange_t + stable_partition(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted } template, O2> constexpr partition_copy_result, O1, O2> partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O1, @\libconcept{sized_sentinel_for}@ OutS1, + @\libconcept{random_access_iterator}@ O2, @\libconcept{sized_sentinel_for}@ OutS2, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ && @\libconcept{indirectly_copyable}@ + partition_copy_result + partition_copy(Ep&& exec, I first, S last, O1 out_true, OutS1 last_true, + O2 out_false, OutS2 last_false, Pred pred, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + @\exposconcept{sized-random-access-range}@ OutR1, @\exposconcept{sized-random-access-range}@ OutR2, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirectly_copyable}@, iterator_t> + partition_copy_result, borrowed_iterator_t, + borrowed_iterator_t> + partition_copy(Ep&& exec, R&& r, OutR1&& out_true_r, OutR2&& out_false_r, Pred pred, + Proj proj = {}); // freestanding-deleted } template @@ -2627,6 +3383,22 @@ constexpr merge_result, borrowed_iterator_t, O> merge(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + merge_result + merge(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, O result, OutS result_last, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, Comp, Proj1, Proj2> + merge_result, borrowed_iterator_t, borrowed_iterator_t> + merge(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } template @@ -2658,6 +3430,18 @@ requires @\libconcept{sortable}@, Comp, Proj> constexpr borrowed_iterator_t inplace_merge(R&& r, iterator_t middle, Comp comp = {}, Proj proj = {}); // hosted + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I inplace_merge(Ep&& exec, I first, I middle, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + inplace_merge(Ep&& exec, R&& r, iterator_t middle, Comp comp = {}, + Proj proj = {}); // freestanding-deleted } // \ref{alg.set.operations}, set operations @@ -2692,6 +3476,20 @@ projected, Proj2>> Comp = ranges::less> constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, projected> Comp = + ranges::less> + bool includes(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, Proj1>, + projected, Proj2>> Comp = ranges::less> + bool includes(Ep&& exec, R1&& r1, R2&& r2, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } template @@ -2736,6 +3534,25 @@ constexpr set_union_result, borrowed_iterator_t, O> set_union(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + set_union_result + set_union(Ep&& exec, I1 first1, S1 last1, + I2 first2, S2 last2, O result, OutS result_last, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + set_union_result, borrowed_iterator_t, + borrowed_iterator_t> + set_union(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } template @@ -2780,6 +3597,25 @@ constexpr set_intersection_result, borrowed_iterator_t, O> set_intersection(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + set_intersection_result + set_intersection(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + O result, OutS result_last, Comp comp = {}, Proj1 proj1 = {}, + Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + set_intersection_result, borrowed_iterator_t, + borrowed_iterator_t> + set_intersection(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } template @@ -2824,6 +3660,25 @@ constexpr set_difference_result, O> set_difference(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + set_difference_result + set_difference(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + O result, OutS result_last, Comp comp = {}, Proj1 proj1 = {}, + Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + set_difference_result, borrowed_iterator_t, + borrowed_iterator_t> + set_difference(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } template @@ -2870,6 +3725,25 @@ borrowed_iterator_t, O> set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + set_symmetric_difference_result + set_symmetric_difference(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + O result, OutS result_last, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + set_symmetric_difference_result, borrowed_iterator_t, + borrowed_iterator_t> + set_symmetric_difference(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.heap.operations}, heap operations @@ -2965,6 +3839,15 @@ template<@\libconcept{random_access_range}@ R, class Proj = identity, @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + bool is_heap(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + bool is_heap(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -2992,6 +3875,16 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I is_heap_until(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + is_heap_until(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } // \ref{alg.min.max}, minimum and maximum @@ -3015,6 +3908,11 @@ requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> constexpr range_value_t min(R&& r, Comp comp = {}, Proj proj = {}); + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> + range_value_t + min(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template constexpr const T& max(const T& a, const T& b); @@ -3037,6 +3935,11 @@ requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> constexpr range_value_t max(R&& r, Comp comp = {}, Proj proj = {}); + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> + range_value_t + max(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template constexpr pair minmax(const T& a, const T& b); @@ -3064,6 +3967,11 @@ requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> constexpr minmax_result> minmax(R&& r, Comp comp = {}, Proj proj = {}); + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> + minmax_result> + minmax(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -3087,6 +3995,17 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t min_element(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I min_element(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + min_element(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -3110,6 +4029,17 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t max_element(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I max_element(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + max_element(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } template @@ -3139,6 +4069,17 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr minmax_element_result> minmax_element(R&& r, Comp comp = {}, Proj proj = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + minmax_element_result + minmax_element(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + minmax_element_result> + minmax_element(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); // freestanding-deleted } // \ref{alg.clamp}, bounded value @@ -3192,6 +4133,21 @@ constexpr bool lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, + projected> Comp = ranges::less> + bool lexicographical_compare(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Comp comp = {}, Proj1 proj1 = {}, + Proj2 proj2 = {}); // freestanding-deleted + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, Proj1>, + projected, Proj2>> Comp = ranges::less> + bool lexicographical_compare(Ep&& exec, R1&& r1, R2&& r2, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // freestanding-deleted } // \ref{alg.three.way}, three-way comparison algorithms @@ -3455,6 +4411,13 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool ranges::all_of(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool ranges::all_of(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -3495,6 +4458,13 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool ranges::any_of(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool ranges::any_of(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -3535,6 +4505,13 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool ranges::none_of(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool ranges::none_of(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -3578,6 +4555,24 @@ \tcode{ranges::find(std::move(first), last, value, proj) != last}. \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + bool ranges::contains(Ep&& exec, I first, S last, const T& value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + bool ranges::contains(Ep&& exec, R&& r, const T& value, Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{ranges::find(std::forward(exec), first, last, value, proj) != last}. +\end{itemdescr} + \indexlibraryglobal{contains_subrange}% \begin{itemdecl} template<@\libconcept{forward_iterator}@ I1, @\libconcept{sentinel_for}@ S1, @@ -3599,6 +4594,29 @@ \tcode{first2 == last2 || !ranges::search(first1, last1, first2, last2, pred, proj1, proj2).empty()}. \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool ranges::contains_subrange(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool ranges::contains_subrange(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +first2 == last2 || !ranges::search(std::forward(exec), first1, last1, + first2, last2, pred, proj1, proj2).empty() +\end{codeblock} +\end{itemdescr} + \rSec2[alg.foreach]{For each} \indexlibraryglobal{for_each}% @@ -3722,6 +4740,54 @@ \end{note} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirectly_unary_invocable}@> Fun> + I ranges::for_each(Ep&& exec, I first, S last, Fun f, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirectly_unary_invocable}@, Proj>> Fun> + borrowed_iterator_t + ranges::for_each(Ep&& exec, R&& r, Fun f, Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Calls \tcode{invoke(f, invoke(proj, *i))} +for every iterator \tcode{i} +in the range \range{first}{last}. +\begin{note} +If the result of \tcode{invoke(proj, *i)} is a mutable reference, +\tcode{f} can apply non-constant functions. +\end{note} + +\pnum +\returns +\tcode{last}. + +\pnum +\complexity +Applies \tcode{f} and \tcode{proj} exactly \tcode{last - first} times. + +\pnum +\remarks +\begin{itemize} +\item + If \tcode{f} returns a result, the result is ignored. +\item + Implementations do not have the freedom granted under \ref{algorithms.parallel.exec} + to make arbitrary copies of elements from the input sequence. +\item + \tcode{f} may modify objects via its arguments\iref{algorithms.parallel.user}. +\end{itemize} +\begin{note} +Does not return a copy of its \tcode{Fun} parameter, +since parallelization often does not permit +efficient state accumulation. +\end{note} +\end{itemdescr} + \indexlibraryglobal{for_each_n}% \begin{itemdecl} template @@ -3838,6 +4904,53 @@ \end{note} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, class Proj = identity, + @\libconcept{indirectly_unary_invocable}@> Fun> + I ranges::for_each_n(Ep&& exec, I first, iter_difference_t n, Fun f, Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\expects +\tcode{n >= 0} is \tcode{true}. + +\pnum +\effects +Calls \tcode{invoke(f, invoke(proj, *i))} +for every iterator \tcode{i} +in the range \range{first}{first + n}. +\begin{note} +If the result of \tcode{invoke(proj, *i)} is a mutable reference, +\tcode{f} can apply non-constant functions. +\end{note} + +\pnum +\returns +\tcode{first + n}. + +\pnum +\complexity +Applies \tcode{f} and \tcode{proj} exactly \tcode{last - first} times. + +\pnum +\remarks +\begin{itemize} +\item + If \tcode{f} returns a result, the result is ignored. +\item + Implementations do not have the freedom granted under \ref{algorithms.parallel.exec} + to make arbitrary copies of elements from the input sequence. +\item + \tcode{f} may modify objects via its arguments\iref{algorithms.parallel.user}. +\end{itemize} +\begin{note} +Does not return a copy of its \tcode{Fun} parameter, +since parallelization often does not permit +efficient state accumulation. +\end{note} +\end{itemdescr} + \rSec2[alg.find]{Find} \indexlibraryglobal{find}% @@ -3875,6 +4988,17 @@ requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> constexpr borrowed_iterator_t ranges::find(R&& r, const T& value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + I ranges::find(Ep&& exec, I first, S last, const T& value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + borrowed_iterator_t ranges::find(Ep&& exec, R&& r, const T& value, Proj proj = {}); + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr I ranges::find_if(I first, S last, Pred pred, Proj proj = {}); @@ -3882,6 +5006,14 @@ @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_iterator_t ranges::find_if(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + I ranges::find_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_iterator_t ranges::find_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr I ranges::find_if_not(I first, S last, Pred pred, Proj proj = {}); @@ -3889,6 +5021,13 @@ @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_iterator_t ranges::find_if_not(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + I ranges::find_if_not(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_iterator_t ranges::find_if_not(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -3927,18 +5066,46 @@ class T = projected_value_t, Proj>> requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> constexpr borrowed_subrange_t ranges::find_last(R&& r, const T& value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + subrange ranges::find_last(Ep&& exec, I first, S last, const T& value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + borrowed_subrange_t ranges::find_last(Ep&& exec, R&& r, const T& value, Proj proj = {}); + template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr subrange ranges::find_last_if(I first, S last, Pred pred, Proj proj = {}); template<@\libconcept{forward_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_subrange_t ranges::find_last_if(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + subrange ranges::find_last_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_subrange_t ranges::find_last_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); + template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr subrange ranges::find_last_if_not(I first, S last, Pred pred, Proj proj = {}); template<@\libconcept{forward_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr borrowed_subrange_t ranges::find_last_if_not(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@> Pred> + subrange ranges::find_last_if_not(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + borrowed_subrange_t ranges::find_last_if_not(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -4006,6 +5173,20 @@ constexpr borrowed_subrange_t ranges::find_end(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + subrange + ranges::find_end(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + borrowed_subrange_t + ranges::find_end(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -4092,6 +5273,19 @@ ranges::find_first_of(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + I1 ranges::find_first_of(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + borrowed_iterator_t + ranges::find_first_of(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -4152,6 +5346,17 @@ @\libconcept{indirect_binary_predicate}@, Proj>, projected, Proj>> Pred = ranges::equal_to> constexpr borrowed_iterator_t ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_binary_predicate}@, + projected> Pred = ranges::equal_to> + I ranges::adjacent_find(Ep&& exec, I first, S last, Pred pred = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_binary_predicate}@, Proj>, + projected, Proj>> Pred = ranges::equal_to> + borrowed_iterator_t + ranges::adjacent_find(Ep&& exec, R&& r, Pred pred = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -4173,13 +5378,13 @@ \pnum \complexity -For the overloads with no \tcode{ExecutionPolicy}, +For the non-parallel algorithm overloads, exactly \[ \min(\tcode{(i - first) + 1}, \ \tcode{(last - first) - 1}) \] applications of the corresponding predicate, where \tcode{i} is \tcode{adjacent_find}'s return value. -For the overloads with an \tcode{ExecutionPolicy}, -\bigoh{\tcode{last - first}} applications of the corresponding predicate, -and no more than twice as many applications of any projection. +For the parallel algorithm overloads, +\bigoh{\tcode{last - first}} applications of the corresponding predicate. +No more than twice as many applications of any projection. \end{itemdescr} \rSec2[alg.count]{Count} @@ -4213,6 +5418,18 @@ requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> constexpr range_difference_t ranges::count(R&& r, const T& value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + iter_difference_t + ranges::count(Ep&& exec, I first, S last, const T& value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + range_difference_t ranges::count(Ep&& exec, R&& r, const T& value, Proj proj = {}); + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr iter_difference_t @@ -4221,6 +5438,15 @@ @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr range_difference_t ranges::count_if(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + iter_difference_t + ranges::count_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + range_difference_t + ranges::count_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -4314,12 +5540,26 @@ constexpr ranges::mismatch_result, borrowed_iterator_t> ranges::mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + ranges::mismatch_result + ranges::mismatch(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + ranges::mismatch_result, borrowed_iterator_t> + ranges::mismatch(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} \pnum Let \tcode{last2} be \tcode{first2 + (last1 - first1)} -for the overloads with no parameter \tcode{last2} or \tcode{r2}. +for the overloads in namespace \tcode{std} with no parameter \tcode{last2}. \pnum Let $E$ be: @@ -4404,6 +5644,18 @@ requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool ranges::equal(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool ranges::equal(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -4412,7 +5664,7 @@ \begin{itemize} \item \tcode{last2} be \tcode{first2 + (last1 - first1)} - for the overloads with no parameter \tcode{last2} or \tcode{r2}; + for the overloads in namespace \tcode{std} with no parameter \tcode{last2}; \item \tcode{pred} be \tcode{equal_to\{\}} for the overloads with no parameter \tcode{pred}; @@ -4447,27 +5699,20 @@ and \tcode{last1 - first1 != last2 - first2} for the overloads in namespace \tcode{std}; \item - the types of \tcode{first1}, \tcode{last1}, \tcode{first2}, and \tcode{last2} - pairwise model \libconcept{sized_sentinel_for}\iref{iterator.concept.sizedsentinel} + the types of \tcode{first1}, \tcode{last1}, \tcode{first2}, and \tcode{last2} + pairwise model \libconcept{sized_sentinel_for}\iref{iterator.concept.sizedsentinel} and \tcode{last1 - first1 != last2 - first2} - for the first overload in namespace \tcode{ranges}, + for the first and third overloads in namespace \tcode{ranges}, or \item \tcode{R1} and \tcode{R2} each model \libconcept{sized_range} and \tcode{ranges::distance(r1) != ranges::distance(r2)} - for the second overload in namespace \tcode{ranges}, + for the second and fourth overloads in namespace \tcode{ranges}, \end{itemize} then no applications of the corresponding predicate and each projection; -otherwise, -\begin{itemize} -\item - For the overloads with no \tcode{ExecutionPolicy}, - at most $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ - applications of the corresponding predicate and any projections. -\item - For the overloads with an \tcode{ExecutionPolicy}, - \bigoh{\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})} - applications of the corresponding predicate. -\end{itemize} +%FIXME: "At" should be lower because presumably, +%the intent was to remove bullets here instead of creating a single-bullet list. +otherwise, At most $\min(\brk{}\tcode{last1 - first1},\brk{} \ \tcode{last2 - first2})$ +applications of the corresponding predicate and any projections. \end{itemdescr} \rSec2[alg.is.permutation]{Is permutation} @@ -4640,6 +5885,20 @@ constexpr borrowed_subrange_t ranges::search(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + subrange + ranges::search(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + borrowed_subrange_t + ranges::search(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -4735,6 +5994,20 @@ constexpr borrowed_subrange_t ranges::search_n(R&& r, range_difference_t count, const T& value, Pred pred = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Pred = ranges::equal_to, class Proj = identity, + class T = projected_value_t> + requires @\libconcept{indirectly_comparable}@ + subrange + ranges::search_n(Ep&& exec, I first, S last, iter_difference_t count, + const T& value, Pred pred = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Pred = ranges::equal_to, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirectly_comparable}@, const T*, Pred, Proj> + borrowed_subrange_t + ranges::search_n(Ep&& exec, R&& r, range_difference_t count, + const T& value, Pred pred = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -4795,6 +6068,30 @@ \end{codeblock} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool ranges::starts_with(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, + @\exposconcept{sized-random-access-range}@ R2, class Pred = ranges::equal_to, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool ranges::starts_with(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +ranges::mismatch(std::forward(exec), std::move(first1), last1, std::move(first2), + last2, pred, proj1, proj2).in2 == last2 +\end{codeblock} +\end{itemdescr} + \rSec2[alg.ends.with]{Ends with} \indexlibraryglobal{ends_with}% @@ -4822,6 +6119,29 @@ \end{codeblock} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@ + bool ranges::ends_with(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +Let \tcode{N1} be \tcode{ranges::distance(r1)} and +\tcode{N2} be \tcode{ranges::distance(r2)}. + +\pnum +\returns +\tcode{false} if $\tcode{N1} < \tcode{N2}$, otherwise +\begin{codeblock} +ranges::equal(std::forward(exec), std::move(first1) + (N1 - N2), last1, + std::move(first2), last2, pred, proj1, proj2) +\end{codeblock} +\end{itemdescr} + \begin{itemdecl} template<@\libconcept{input_range}@ R1, @\libconcept{input_range}@ R2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> @@ -4846,6 +6166,30 @@ \end{codeblock} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, + @\exposconcept{sized-random-access-range}@ R2, class Pred = ranges::equal_to, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_comparable}@, iterator_t, Pred, Proj1, Proj2> + bool ranges::ends_with(Ep&& exec, R1&& r1, R2&& r2, + Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +Let \tcode{N1} be \tcode{ranges::distance(r1)} and +\tcode{N2} be \tcode{ranges::distance(r2)}. + +\pnum +\returns +\tcode{false} if $\tcode{N1} < \tcode{N2}$, otherwise +\begin{codeblock} +ranges::equal(std::forward(exec), + views::drop(ranges::ref_view(r1), N1 - static_cast(N2)), + r2, pred, proj1, proj2) +\end{codeblock} +\end{itemdescr} + \rSec2[alg.fold]{Fold} \indexlibraryglobal{fold_left}% @@ -5067,28 +6411,50 @@ ForwardIterator2 copy(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + ranges::copy_result + ranges::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> + ranges::copy_result, borrowed_iterator_t> + ranges::copy(Ep&& exec, R&& r, OutR&& result_r); \end{itemdecl} \begin{itemdescr} +\pnum +Let \tcode{result_last} be \tcode{result + (last - first)} +for the overload in namespace \tcode{std}. + +\pnum +Let $N$ be $\min(\tcode{last - first}, \ \tcode{result_last - result})$ + \pnum \expects -The ranges \range{first}{last} and \range{result}{result + (last - first)} +The ranges \range{first}{last} and \range{result}{result + $N$} do not overlap. \pnum \effects -Copies elements in the range \range{first}{last} -into the range \range{result}{result + (last - first)}. -For each non-negative integer \tcode{n < (last - first)}, -performs \tcode{*(result + n) = *(first + n)}. +Copies elements in the range \range{first}{first + $N$} +into the range \range{result}{result + $N$}. +For each non-negative integer $n < N$, +performs \tcode{*(result + $n$) = *(first + $n$)}. \pnum \returns -\tcode{result + (last - first)}. +\begin{itemize} +\item + \tcode{result + $N$} for the overload in namespace \tcode{std}. +\item + \tcode{\{first + $N$, result + $N$\}} for the overloads in namespace \tcode{ranges}. +\end{itemize} \pnum \complexity -Exactly \tcode{last - first} assignments. +Exactly $N$ assignments. \end{itemdescr} \indexlibraryglobal{copy_n}% @@ -5105,11 +6471,24 @@ requires @\libconcept{indirectly_copyable}@ constexpr ranges::copy_n_result ranges::copy_n(I first, iter_difference_t n, O result); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{random_access_iterator}@ O, + @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + ranges::copy_n_result + ranges::copy_n(Ep&& exec, I first, iter_difference_t n, O result, OutS result_last); \end{itemdecl} \begin{itemdescr} \pnum -Let $N$ be $\max(0, \tcode{n})$. +Let $M$ be $\max(0, \ \tcode{n})$. + +\pnum +Let \tcode{result_last} be \tcode{result + $M$} +for the overloads with no parameter \tcode{result_last}. + +\pnum +Let $N$ be $\min(\tcode{result_last - result}, M)$. \pnum \mandates @@ -5158,38 +6537,67 @@ requires @\libconcept{indirectly_copyable}@, O> constexpr ranges::copy_if_result, O> ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ + ranges::copy_if_result + ranges::copy_if(Ep&& exec, I first, S last, O result, OutS result_last, + Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> + ranges::copy_if_result, borrowed_iterator_t> + ranges::copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} \pnum -Let $E$ be: +Let $E(\tcode{i})$ be: \begin{itemize} \item \tcode{bool(pred(*i))} for the overloads in namespace \tcode{std}; \item \tcode{bool(invoke(pred, invoke(proj, *i)))} - for the overloads in namespace \tcode{ranges}, + for the overloads in namespace \tcode{ranges}. +\end{itemize} + +\pnum +Let: +\begin{itemize} +\item + $M$ be the number of iterators \tcode{i} in the range \range{first}{last} + for which the condition $E(\tcode{i})$ holds; +\item + \tcode{result_last} be \tcode{result + $M$} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(M, \ \tcode{result_last - result})$. \end{itemize} -and $N$ be the number of iterators \tcode{i} in the range \range{first}{last} -for which the condition $E$ holds. \pnum \expects -The ranges \range{first}{last} and \range{result}{result + (last - first)} +The ranges \range{first}{last} and \range{result}{result + $N$} do not overlap. \begin{note} -For the overload with an \tcode{ExecutionPolicy}, -there might be a performance cost +For the parallel algorithm overload in namespace \tcode{std}, +there can be a performance cost if \tcode{iterator_traits::value_type} -is not \oldconcept{\-Move\-Constructible} (\tref{cpp17.moveconstructible}). +does not meet the \oldconcept{\-Move\-Constructible} (\tref{cpp17.moveconstructible}) requirements. +For the parallel algorithm overloads in namespace \tcode{ranges}, +there can be a performance cost +if \tcode{iter_value_t} does not model \libconcept{move_constructible}. \end{note} \pnum \effects -Copies all of the elements referred to +Copies the first $N$ elements referred to by the iterator \tcode{i} in the range \range{first}{last} -for which $E$ is \tcode{true}. +for which $E(\tcode{i})$ is \tcode{true} +into the range \range{result}{result + $N$}. \pnum \returns @@ -5200,11 +6608,18 @@ \item \tcode{\{last, result + $N$\}} for the overloads in namespace \tcode{ranges}. +\item + Otherwise, \tcode{\{j, result_last\}} + for the overloads in namespace \tcode{ranges}, + where \tcode{j} is the iterator in \range{first}{last} + for which $E(\tcode{j})$ holds + and there are exactly $N$ iterators \tcode{i} + in \range{first}{j} for which $E(\tcode{i})$ holds. \end{itemize} \pnum \complexity -Exactly \tcode{last - first} applications +At most \tcode{last - first} applications of the corresponding predicate and any projection. \pnum @@ -5330,11 +6745,40 @@ ForwardIterator2 move(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_movable}@ + ranges::move_result + ranges::move(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_movable}@, iterator_t> + ranges::move_result, borrowed_iterator_t> + ranges::move(Ep&& exec, R&& r, OutR&& result_r); \end{itemdecl} \begin{itemdescr} \pnum -Let $N$ be \tcode{last - first}. +Let $E$ be: +\begin{itemize} +\item + %FIXME: This is extremely confusing to read from top to bottom + % because $n$ is defined multiple paragraphs below. + % Can we make this $E(\tcode{i})$ or something? + % We did that for copy_if. + \tcode{std::move(*(first + $n$))} + for the overload in namespace \tcode{std}; +\item + \tcode{ranges::iter_move(first + $n$)} + for the overloads in namespace \tcode{ranges}. +\end{itemize} + +\pnum +Let \tcode{result_last} be \tcode{result + (last - first)} +for the overloads in namespace \tcode{std}. + +\pnum +Let $N$ be $\min(\tcode{last - first}, \ \tcode{result_last - result})$. \pnum \expects @@ -5343,14 +6787,21 @@ \pnum \effects -Moves elements in the range \range{first}{last} +Moves elements in the range \range{first}{first + $N$} into the range \range{result}{result + $N$}. For each non-negative integer $n < N$, -performs \tcode{*(result + $n$) = std::\brk{}move(*(first + $n$))}. +performs \tcode{*(result + $n$) = $E$}. \pnum \returns -\tcode{result + $N$}. +\begin{itemize} +\item + \tcode{result + $N$} + for the overload in namespace \tcode{std}. +\item + \tcode{\{first + $N$, result + $N$\}} + for the overloads in namespace \tcode{ranges}. +\end{itemize} \pnum \complexity @@ -5441,6 +6892,16 @@ requires @\libconcept{indirectly_swappable}@, iterator_t> constexpr ranges::swap_ranges_result, borrowed_iterator_t> ranges::swap_ranges(R1&& r1, R2&& r2); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2> + requires @\libconcept{indirectly_swappable}@ + ranges::swap_ranges_result + ranges::swap_ranges(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2> + requires @\libconcept{indirectly_swappable}@, iterator_t> + ranges::swap_ranges_result, borrowed_iterator_t> + ranges::swap_ranges(Ep&& exec, R1&& r1, R2&& r2); \end{itemdecl} \begin{itemdescr} @@ -5449,7 +6910,8 @@ \begin{itemize} \item \tcode{last2} be \tcode{first2 + (last1 - first1)} - for the overloads with no parameter named \tcode{last2}; + for the overloads in namespace \tcode{std} + with no parameter named \tcode{last2}; \item $M$ be $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$. \end{itemize} @@ -5546,6 +7008,21 @@ requires @\libconcept{indirectly_writable}@, Proj>>> constexpr ranges::unary_transform_result, O> ranges::transform(R&& r, O result, F op, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + @\libconcept{copy_constructible}@ F, class Proj = identity> + requires @\libconcept{indirectly_writable}@>> + ranges::unary_transform_result + ranges::transform(Ep&& exec, I first1, S last1, O result, OutS result_last, + F op, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + @\libconcept{copy_constructible}@ F, class Proj = identity> + requires @\libconcept{indirectly_writable}@, + indirect_result_t, Proj>>> + ranges::unary_transform_result, borrowed_iterator_t> + ranges::transform(Ep&& exec, R&& r, OutR&& result_r, F op, Proj proj = {}); + template<@\libconcept{input_iterator}@ I1, @\libconcept{sentinel_for}@ S1, @\libconcept{input_iterator}@ I2, @\libconcept{sentinel_for}@ S2, @\libconcept{weakly_incrementable}@ O, @\libconcept{copy_constructible}@ F, class Proj1 = identity, class Proj2 = identity> @@ -5561,6 +7038,27 @@ constexpr ranges::binary_transform_result, borrowed_iterator_t, O> ranges::transform(R1&& r1, R2&& r2, O result, F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + @\libconcept{copy_constructible}@ F, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_writable}@, + projected>> + ranges::binary_transform_result + ranges::transform(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + O result, OutS result_last, + F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, @\libconcept{copy_constructible}@ F, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_writable}@, + indirect_result_t, Proj1>, + projected, Proj2>>> + ranges::binary_transform_result, borrowed_iterator_t, + borrowed_iterator_t> + ranges::transform(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, + F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -5570,11 +7068,17 @@ \setlength{\emergencystretch}{1em} \item \tcode{last2} be \tcode{first2 + (last1 - first1)} - for the overloads with parameter \tcode{first2} + for the overloads in namespace \tcode{std} + with parameter \tcode{first2} but no parameter \tcode{last2}; \item - $N$ be \tcode{last1 - first1} for unary transforms, or + $M$ be \tcode{last1 - first1} for unary transforms, or $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ for binary transforms; +\item + \tcode{result_last} be \tcode{result + $M$} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(M, \ \tcode{result_last - result})$; \item $E$ be \begin{itemize} @@ -5595,6 +7099,10 @@ \pnum \expects +For parallel algorithm overloads +%FIXME: Comma! +\tcode{op} and \tcode{binary_op} satisfy the requirements +specified in \ref{algorithms.parallel.user}. \tcode{op} and \tcode{binary_op} do not invalidate iterators or subranges, nor modify elements in the ranges \begin{itemize} @@ -5630,7 +7138,7 @@ \complexity Exactly $N$ applications of \tcode{op} or \tcode{binary_op}, and any projections. -This requirement also applies to the overload with an \tcode{ExecutionPolicy}. +This requirement also applies to the parallel algorithm overloads. \pnum \remarks @@ -5673,6 +7181,22 @@ @\libconcept{indirect_binary_predicate}@, Proj>, const T1*> constexpr borrowed_iterator_t ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T1 = projected_value_t, class T2 = T1> + requires @\libconcept{indirectly_writable}@ && + @\libconcept{indirect_binary_predicate}@, const T1*> + I ranges::replace(Ep&& exec, I first, S last, + const T1& old_value, const T2& new_value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T1 = projected_value_t, Proj>, class T2 = T1> + requires @\libconcept{indirectly_writable}@, const T2&> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T1*> + borrowed_iterator_t + ranges::replace(Ep&& exec, R&& r, const T1& old_value, const T2& new_value, + Proj proj = {}); + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, class T = projected_value_t, @\libconcept{indirect_unary_predicate}@> Pred> @@ -5683,6 +7207,19 @@ requires @\libconcept{indirectly_writable}@, const T&> constexpr borrowed_iterator_t ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t, + @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_writable}@ + I ranges::replace_if(Ep&& exec, I first, S last, Pred pred, + const T& new_value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_writable}@, const T&> + borrowed_iterator_t + ranges::replace_if(Ep&& exec, R&& r, Pred pred, const T& new_value, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -5761,6 +7298,27 @@ ranges::replace_copy(R&& r, O result, const T1& old_value, const T2& new_value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, + class T1 = projected_value_t, class T2 = iter_value_t> + requires @\libconcept{indirectly_copyable}@ && + @\libconcept{indirect_binary_predicate}@, const T1*> && + @\libconcept{indirectly_writable}@ + ranges::replace_copy_result + ranges::replace_copy(Ep&& exec, I first, S last, O result, OutS result_last, + const T1& old_value, const T2& new_value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, class T1 = projected_value_t, Proj>, + class T2 = range_value_t> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T1*> && + @\libconcept{indirectly_writable}@, const T2&> + ranges::replace_copy_result, borrowed_iterator_t> + ranges::replace_copy(Ep&& exec, R&& r, OutR&& result_r, const T1& old_value, + const T2& new_value, Proj proj = {}); + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S,class O, class T = iter_value_t, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> requires @\libconcept{indirectly_copyable}@ && @\libconcept{output_iterator}@ @@ -5773,6 +7331,22 @@ constexpr ranges::replace_copy_if_result, O> ranges::replace_copy_if(R&& r, O result, Pred pred, const T& new_value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class T = iter_value_t, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ && @\libconcept{indirectly_writable}@ + ranges::replace_copy_if_result + ranges::replace_copy_if(Ep&& exec, I first, S last, O result, OutS result_last, + Pred pred, const T& new_value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class T = range_value_t, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirectly_writable}@ + ranges::replace_copy_if_result, borrowed_iterator_t> + ranges::replace_copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, const T& new_value, + Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -5790,6 +7364,16 @@ for \tcode{ranges::replace_\-copy_if}. \end{itemize} +\pnum +Let %FIXME: missing colon +\begin{itemize} +\item + \tcode{result_last} be \tcode{result + (last - first)} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(\tcode{last - first}, \ \tcode{result_last - result})$. +\end{itemize} + \pnum \mandates The results of the expressions \tcode{*first} and \tcode{new_value} @@ -5797,13 +7381,13 @@ \pnum \expects -The ranges \range{first}{last} and \range{result}{result + (last - first)} +The ranges \range{first}{last} and \range{result}{result + $N$} do not overlap. \pnum \effects Assigns through every iterator \tcode{i} -in the range \range{result}{result + (last - first)} +in the range \range{result}{result + $N$} a new corresponding value \begin{itemize} \item \tcode{new_value} if $E$ is \tcode{true} or @@ -5814,16 +7398,16 @@ \returns \begin{itemize} \item - \tcode{result + (last - first)} + \tcode{result + $N$} for the overloads in namespace \tcode{std}. \item - \tcode{\{last, result + (last - first)\}} + \tcode{\{first + $N$, result + $N$\}} for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -Exactly \tcode{last - first} applications +Exactly $N$ applications of the corresponding predicate and any projection. \end{itemdescr} @@ -5855,6 +7439,17 @@ template> requires @\libconcept{output_iterator}@ constexpr O ranges::fill_n(O first, iter_difference_t n, const T& value); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ S, + class T = iter_value_t> + requires @\libconcept{indirectly_writable}@ + O ranges::fill(Ep&& exec, O first, S last, const T& value); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class T = range_value_t> + requires @\libconcept{indirectly_writable}@, const T&> + borrowed_iterator_t fill(Ep&& exec, R&& r, const T& value); +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, class T = iter_value_t> + requires @\libconcept{indirectly_writable}@ + O ranges::fill_n(Ep&& exec, O first, iter_difference_t n, const T& value); \end{itemdecl} \begin{itemdescr} @@ -5911,6 +7506,17 @@ template<@\libconcept{input_or_output_iterator}@ O, @\libconcept{copy_constructible}@ F> requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@> constexpr O ranges::generate_n(O first, iter_difference_t n, F gen); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{copy_constructible}@ F> + requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@> + O ranges::generate(Ep&& exec, O first, S last, F gen); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\libconcept{copy_constructible}@ F> + requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@, invoke_result_t> + borrowed_iterator_t ranges::generate(Ep&& exec, R&& r, F gen); +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ O, @\libconcept{copy_constructible}@ F> + requires @\libconcept{invocable}@ && @\libconcept{indirectly_writable}@> + O ranges::generate_n(Ep&& exec, O first, iter_difference_t n, F gen); \end{itemdecl} \begin{itemdescr} @@ -5935,6 +7541,11 @@ \pnum \complexity Exactly $N$ evaluations of \tcode{gen()} and assignments. + +\pnum +\remarks +\tcode{gen} may modify objects via its arguments +for parallel algorithm overloads\iref{algorithms.parallel.user}. \end{itemdescr} \rSec2[alg.remove]{Remove} @@ -5969,6 +7580,20 @@ @\libconcept{indirect_binary_predicate}@, Proj>, const T*> constexpr borrowed_subrange_t ranges::remove(R&& r, const T& value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirect_binary_predicate}@, const T*> + subrange + ranges::remove(Ep&& exec, I first, S last, const T& value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + class T = projected_value_t, Proj>> + requires @\libconcept{permutable}@> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + borrowed_subrange_t + ranges::remove(Ep&& exec, R&& r, const T& value, Proj proj = {}); + template<@\libconcept{permutable}@ I, @\libconcept{sentinel_for}@ S, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> constexpr subrange ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); @@ -5977,6 +7602,16 @@ requires @\libconcept{permutable}@> constexpr borrowed_subrange_t ranges::remove_if(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + subrange + ranges::remove_if(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{permutable}@> + borrowed_subrange_t + ranges::remove_if(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -6065,6 +7700,23 @@ @\libconcept{indirect_binary_predicate}@, Proj>, const T*> constexpr ranges::remove_copy_result, O> ranges::remove_copy(R&& r, O result, const T& value, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, class T = projected_value_t> + requires @\libconcept{indirectly_copyable}@ && + @\libconcept{indirect_binary_predicate}@, const T*> + ranges::remove_copy_result + ranges::remove_copy(Ep&& exec, I first, S last, O result, OutS result_last, + const T& value, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, class T = projected_value_t, Proj>> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirect_binary_predicate}@, Proj>, const T*> + ranges::remove_copy_result, borrowed_iterator_t> + ranges::remove_copy(Ep&& exec, R&& r, OutR&& result_r, const T& value, Proj proj = {}); + template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@ S, @\libconcept{weakly_incrementable}@ O, class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> requires @\libconcept{indirectly_copyable}@ @@ -6075,11 +7727,25 @@ requires @\libconcept{indirectly_copyable}@, O> constexpr ranges::remove_copy_if_result, O> ranges::remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ + ranges::remove_copy_if_result + ranges::remove_copy_if(Ep&& exec, I first, S last, O result, OutS result_last, + Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> + ranges::remove_copy_if_result, borrowed_iterator_t> + ranges::remove_copy_if(Ep&& exec, R&& r, OutR&& result_r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} \pnum -Let $E$ be +Let $E(\tcode{i})$ be \begin{itemize} \item \tcode{bool(*i == value)} for \tcode{remove_copy}; \item \tcode{bool(pred(*i))} for \tcode{remove_copy_if}; @@ -6088,8 +7754,17 @@ \end{itemize} \pnum -Let $N$ be the number of elements in \range{first}{last} -for which $E$ is \tcode{false}. +Let %FIXME: missing colon +\begin{itemize} +\item + $M$ be the number of iterators \tcode{i} in \range{first}{last} + for which $E(\tcode{i})$ is \tcode{false}; +\item + \tcode{result_last} be \tcode{result + $M$} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(M, \ \tcode{result_last - result})$. +\end{itemize} \pnum \mandates @@ -6097,30 +7772,46 @@ \pnum \expects -The ranges \range{first}{last} and \range{result}{result + (last - first)} +The ranges \range{first}{last} and \range{result}{result + $N$} do not overlap. \begin{note} -For the overloads with an \tcode{ExecutionPolicy}, -there might be a performance cost +For the parallel algorithm overloads in namespace \tcode{std}, +there can be a performance cost if \tcode{iterator_traits::value_type} does not meet the \oldconcept{\-Move\-Constructible} (\tref{cpp17.moveconstructible}) requirements. +For the parallel algorithm overloads in namespace \tcode{ranges}, +there can be a performance cost +if \tcode{iter_value_t} does not model \libconcept{move_constructible}. \end{note} \pnum \effects -Copies all the elements referred to by the iterator \tcode{i} -in the range \range{first}{last} for which $E$ is \tcode{false}. +Copies the first $N$ elements referred to by the iterator \tcode{i} +in the range \range{first}{last} for which $E(\tcode{i})$ is \tcode{false} +into the range \range{result}{result + $N$}. \pnum \returns \begin{itemize} -\item \tcode{result + $N$}, for the algorithms in namespace \tcode{std}. -\item \tcode{\{last, result + $N$\}}, for the algorithms in namespace \tcode{ranges}. +\item + \tcode{result + $N$}, + for the algorithms in namespace \tcode{std}. +\item + \tcode{\{last, result + $N$\}}, + for the algorithms in namespace \tcode{ranges}, + if $N$ is equal to $M$. +\item + Otherwise, \tcode{\{j, result_last\}}, + for the algorithms in namespace \tcode{ranges}, + where \tcode{j} is the iterator in \range{first}{last} + for which $E(\tcode{j})$ is \tcode{false} + and there are exactly $N$ iterators \tcode{i} in \range{first}{j} + for which $E(\tcode{j})$ is \tcode{false}. \end{itemize} \pnum \complexity -Exactly \tcode{last - first} applications +At most \tcode{last - first} applications of the corresponding predicate and any projection. \pnum @@ -6154,6 +7845,16 @@ requires @\libconcept{permutable}@> constexpr borrowed_subrange_t ranges::unique(R&& r, C comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_equivalence_relation}@> C = ranges::equal_to> + requires @\libconcept{permutable}@ + subrange ranges::unique(Ep&& exec, I first, S last, C comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_equivalence_relation}@, Proj>> C = ranges::equal_to> + requires @\libconcept{permutable}@> + borrowed_subrange_t ranges::unique(Ep&& exec, R&& r, C comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -6240,13 +7941,27 @@ @\libconcept{indirectly_copyable_storable}@, O>) constexpr ranges::unique_copy_result, O> ranges::unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Proj = identity, + @\libconcept{indirect_equivalence_relation}@> C = ranges::equal_to> + requires @\libconcept{indirectly_copyable}@ + ranges::unique_copy_result + ranges::unique_copy(Ep&& exec, I first, S last, O result, OutS result_last, + C comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, @\exposconcept{sized-random-access-range}@ OutR, + class Proj = identity, + @\libconcept{indirect_equivalence_relation}@, Proj>> C = ranges::equal_to> + requires @\libconcept{indirectly_copyable}@, iterator_t> + ranges::unique_copy_result, borrowed_iterator_t> + ranges::unique_copy(Ep&& exec, R&& r, OutR&& result_r, C comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} \pnum Let \tcode{pred} be \tcode{equal_to\{\}} for the overloads in namespace \tcode{std} with no parameter \tcode{pred}, and -let $E$ be +let $E(\tcode{i})$ be \begin{itemize} \setlength{\emergencystretch}{1em} \item @@ -6257,6 +7972,19 @@ for the overloads in namespace \tcode{ranges}. \end{itemize} +\pnum +Let %FIXME: Colon. +\begin{itemize} +\item + $M$ be the number of iterators \tcode{i} in the range \range{first + 1}{last} + for which $E(\tcode{i})$ is \tcode{false}; +\item + \tcode{result_last} be \tcode{result + $M$ + 1} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(\tcode{$M$ + 1}, \ \tcode{result_last - result})$. +\end{itemize} + \pnum \mandates \tcode{*first} is writable\iref{iterator.requirements.general} to \tcode{result}. @@ -6265,7 +7993,7 @@ \expects \begin{itemize} \item - The ranges \range{first}{last} and \range{result}{result + (last - first)} + The ranges \range{first}{last} and \range{result}{result + $N$} do not overlap. \item For the overloads in namespace \tcode{std}: @@ -6286,31 +8014,51 @@ Otherwise, \tcode{T} meets both the \oldconcept{CopyConstructible} (\tref{cpp17.copyconstructible}) and \oldconcept{CopyAssignable} requirements. - \begin{note} - For the overloads with an \tcode{ExecutionPolicy}, - there might be a performance cost - if the value type of \tcode{ForwardIterator1} does not meet both the - \oldconcept{CopyConstructible} and \oldconcept{CopyAssignable} requirements. - \end{note} \end{itemize} \end{itemize} +\begin{note} +For the parallel algorithm overloads in namespace \tcode{std}, +there can be a performance cost +if the value type of \tcode{ForwardIterator1} does not meet both the +\oldconcept{CopyConstructible} and \oldconcept{CopyAssignable} requirements. +For the parallel algorithm overloads in namespace \tcode{ranges}, +there can be a performance cost if \tcode{iter_value_t} +does not model both \libconcept{copy_constructible} +%FIXME: There exists no such concept, +%but the note refers to it. +%LWG input needed. +and \tcode{copy_assignable}. +\end{note} \pnum \effects -Copies only the first element from every consecutive group of equal elements -referred to by the iterator \tcode{i} in the range \range{first}{last} -for which $E$ holds. +Copies only the first element from $N$ consecutive groups of equivalent elements +referred to by the iterator \tcode{i} in the range \range{first + 1}{last} +for which $E(\tcode{i})$ holds +into the range \range{result}{result + $N$}. \pnum \returns \begin{itemize} -\item \tcode{result + $N$} for the overloads in namespace \tcode{std}. -\item \tcode{\{last, result + $N$\}} for the overloads in namespace \tcode{ranges}. +\item + \tcode{result + $N$} + for the overloads in namespace \tcode{std}. +\item + \tcode{\{last, result + $N$\}} + for the overloads in namespace \tcode{ranges}, + if $N$ is equal to \tcode{$M$ + 1}. +\item + Otherwise, \tcode{\{j, result_last\}} + for the overloads in namespace \tcode{ranges}, + where \tcode{j} is the iterator in \range{first + 1}{last} + for which $E(\tcode{j})$ is \tcode{false} + and there are exactly \tcode{$N$ - 1} iterators \tcode{i} in \range{first + 1}{j} + for which $E(\tcode{i})$ is \tcode{false}. \end{itemize} \pnum \complexity -Exactly \tcode{last - first - 1} applications +At most \tcode{last - first - 1} applications of the corresponding predicate and no more than twice as many applications of any projection. \end{itemdescr} @@ -6331,6 +8079,13 @@ template<@\libconcept{bidirectional_range}@ R> requires @\libconcept{permutable}@> constexpr borrowed_iterator_t ranges::reverse(R&& r); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + I ranges::reverse(Ep&& exec, I first, S last); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_iterator_t ranges::reverse(Ep&& exec, R&& r); \end{itemdecl} \begin{itemdescr} @@ -6408,6 +8163,48 @@ Exactly $N$ assignments. \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + ranges::reverse_copy_truncated_result + 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> + ranges::reverse_copy_truncated_result, borrowed_iterator_t> + ranges::reverse_copy(Ep&& exec, R&& r, OutR&& result_r); +\end{itemdecl} + +\begin{itemdescr} +\pnum +Let $N$ be $\min(\tcode{last - first}, \ \tcode{result_last - result})$, +and let \exposid{NEW_FIRST} be \tcode{first + (last - first) - $N$}. + +\pnum +\expects +The ranges \range{first}{last} and \range{result}{result + $N$} +do not overlap. + +\pnum +\effects +Copies the range \range{\exposid{NEW_FIRST}}{last} +to the range \range{result}{result + $N$} +%FIXME: Feels like i should be mathematical instead of code font. +%Otherwise we run into the "is true" situation here: +such that for every non-negative integer \tcode{i < $N$} +the following assignment takes place: +\tcode{*(result + $N$ - 1 - i) = *(\exposid{NEW_FIRST} + i)}. + +\pnum +\returns +\tcode{\{last, \exposid{NEW_FIRST}, result + $N$\}}. + +\pnum +\complexity +Exactly $N$ assignments. +\end{itemdescr} + \rSec2[alg.rotate]{Rotate} \indexlibraryglobal{rotate}% @@ -6473,6 +8270,24 @@ \tcode{return ranges::rotate(ranges::begin(r), middle, ranges::end(r));} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + subrange ranges::rotate(Ep&& exec, I first, I middle, S last); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_subrange_t ranges::rotate(Ep&& exec, R&& r, iterator_t middle); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return ranges::rotate(std::forward(exec), ranges::begin(r), middle, ranges::end(r)); +\end{codeblock} +\end{itemdescr} + \indexlibraryglobal{rotate_copy}% \begin{itemdecl} template @@ -6522,6 +8337,52 @@ Exactly $N$ assignments. \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS> + requires @\libconcept{indirectly_copyable}@ + ranges::rotate_copy_truncated_result + ranges::rotate_copy(Ep&& exec, I first, I middle, S last, O result, OutS result_last); +\end{itemdecl} + +\begin{itemdescr} +\pnum +Let $M$ be \tcode{last - first} +and $N$ be $\min(M, \ \tcode{result_last - result})$. + +\pnum +\expects +\range{first}{middle} and \range{middle}{last} +are valid ranges. +The ranges \range{first}{last} and \range{result}{result + $N$} +do not overlap. + +\pnum +\effects +Copies the range \range{first}{last} +to the range \range{result}{result + $N$} +%FIXME: i has more mathematical vibes than code font vibes. +%This feels wrong. +such that for each non-negative integer \tcode{i < $N$} +the following assignment takes place: +\tcode{*(result + i) = *(first + (i + (middle - first)) \% $M$)}. + +\pnum +\returns +\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 +Exactly $N$ assignments. +\end{itemdescr} + \begin{itemdecl} template<@\libconcept{forward_range}@ R, @\libconcept{weakly_incrementable}@ O> requires @\libconcept{indirectly_copyable}@, O> @@ -6538,6 +8399,23 @@ \end{codeblock} \end{itemdescr} +\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> + ranges::rotate_copy_truncated_result, borrowed_iterator_t> + ranges::rotate_copy(Ep&& exec, R&& r, iterator_t middle, OutR&& result_r); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return ranges::rotate_copy(std::forward(exec), ranges::begin(r), middle, ranges::end(r), + ranges::begin(result_r), ranges::end(result_r)); +\end{codeblock} +\end{itemdescr} + \rSec2[alg.random.sample]{Sample} \indexlibraryglobal{sample}% @@ -6693,6 +8571,16 @@ template<@\libconcept{forward_range}@ R> requires @\libconcept{permutable}@> constexpr borrowed_subrange_t ranges::shift_left(R&& r, range_difference_t n) + // FIXME: semicolon + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + subrange + ranges::shift_left(Ep&& exec, I first, S last, iter_difference_t n); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_subrange_t + ranges::shift_left(Ep&& exec, R&& r, range_difference_t n); \end{itemdecl} \begin{itemdescr} @@ -6709,7 +8597,7 @@ from position \tcode{first + n + i} into position \tcode{first + i} for each non-negative integer \tcode{i < (last - first) - n}. -For the overloads without an \tcode{ExecutionPolicy} template parameter, +For the non-parallel algorithm overloads, does so in order starting from \tcode{i = 0} and proceeding to \tcode{i = (last - first) - n - 1}. @@ -6718,6 +8606,7 @@ Let \exposid{NEW_LAST} be \tcode{first + (last - first - n)} if \tcode{n < last - first}, otherwise \tcode{first}. +Returns: \begin{itemize} \item \exposid{NEW_LAST} for the overloads in namespace \tcode{std}. @@ -6747,6 +8636,15 @@ template<@\libconcept{forward_range}@ R> requires @\libconcept{permutable}@> constexpr borrowed_subrange_t ranges::shift_right(R&& r, range_difference_t n); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S> + requires @\libconcept{permutable}@ + subrange + ranges::shift_right(Ep&& exec, I first, S last, iter_difference_t n); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R> + requires @\libconcept{permutable}@> + borrowed_subrange_t + ranges::shift_right(Ep&& exec, R&& r, range_difference_t n); \end{itemdecl} \begin{itemdescr} @@ -6769,11 +8667,10 @@ from \tcode{i = (last - first) - n - 1} and proceeding to \tcode{i = 0} if \begin{itemize} \item -for the overload in namespace \tcode{std} -without an \tcode{ExecutionPolicy} template parameter, -\tcode{Forward\-Iterator} meets the \oldconcept{BidirectionalIterator} requirements, +for the non-parallel algorithm overload in namespace \tcode{std}, +\tcode{Forward\-Iterator} meets the \oldconcept{\-Bi\-directional\-Iterator} requirements, \item -for the overloads in namespace \tcode{ranges}, +for the non-parallel algorithm overloads in namespace \tcode{ranges}, \tcode{I} models \libconcept{bidirectional_iterator}. \end{itemize} @@ -6781,6 +8678,7 @@ \returns Let \exposid{NEW_FIRST} be \tcode{first + n} if \tcode{n < last - first}, otherwise \tcode{last}. +Returns: \begin{itemize} \item \exposid{NEW_FIRST} for the overloads in namespace \tcode{std}. @@ -6916,6 +8814,15 @@ requires @\libconcept{sortable}@, Comp, Proj> constexpr borrowed_iterator_t ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I ranges::sort(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t ranges::sort(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -6974,6 +8881,16 @@ requires @\libconcept{sortable}@, Comp, Proj> constexpr borrowed_iterator_t ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I ranges::stable_sort(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + ranges::stable_sort(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7043,6 +8960,10 @@ requires @\libconcept{sortable}@ constexpr I ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I ranges::partial_sort(Ep&& exec, I first, I middle, S last, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7097,6 +9018,25 @@ \end{codeblock} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + ranges::partial_sort(Ep&& exec, R&& r, iterator_t middle, Comp comp = {}, + Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return ranges::partial_sort(std::forward(exec), ranges::begin(r), middle, + ranges::end(r), comp, proj); +\end{codeblock} +\end{itemdescr} + \rSec3[partial.sort.copy]{\tcode{partial_sort_copy}} \indexlibraryglobal{partial_sort_copy}% @@ -7145,6 +9085,25 @@ constexpr ranges::partial_sort_copy_result, borrowed_iterator_t> ranges::partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_copyable}@ && @\libconcept{sortable}@ && + @\libconcept{indirect_strict_weak_order}@, projected> + ranges::partial_sort_copy_result + ranges::partial_sort_copy(Ep&& exec, I1 first, S1 last, I2 result_first, S2 result_last, + Comp comp = {}, Proj1 proj1 = {}, + Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{sortable}@, Comp, Proj2> && + @\libconcept{indirect_strict_weak_order}@, Proj1>, + projected, Proj2>> + ranges::partial_sort_copy_result, borrowed_iterator_t> + ranges::partial_sort_copy(Ep&& exec, R1&& r, R2&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -7285,6 +9244,25 @@ \tcode{return ranges::is_sorted_until(first, last, comp, proj) == last;} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + bool ranges::is_sorted(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + bool ranges::is_sorted(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return ranges::is_sorted_until(std::forward(exec), first, last, comp, proj) == last; +\end{codeblock} +\end{itemdescr} + \indexlibraryglobal{is_sorted_until}% \begin{itemdecl} template @@ -7310,8 +9288,18 @@ constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); template<@\libconcept{forward_range}@ R, class Proj = identity, @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> - constexpr borrowed_iterator_t - ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); + constexpr borrowed_iterator_t + ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I ranges::is_sorted_until(Ep&& exec, I first, S last, Comp comp = {}, + Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + ranges::is_sorted_until(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7356,6 +9344,10 @@ requires @\libconcept{sortable}@ constexpr I ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I ranges::nth_element(Ep&& exec, I first, I nth, S last, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7391,8 +9383,8 @@ \pnum \complexity -For the overloads with no \tcode{ExecutionPolicy}, linear on average. -For the overloads with an \tcode{ExecutionPolicy}, \bigoh{N} applications of +For the non-parallel algorithm overloads, linear on average. +For the parallel algorithm overloads, \bigoh{N} applications of the predicate, and \bigoh{N \log N} swaps, where $N = \tcode{last - first}$. \end{itemdescr} @@ -7412,6 +9404,24 @@ \end{codeblock} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + ranges::nth_element(Ep&& exec, R&& r, iterator_t nth, Comp comp = {}, Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return ranges::nth_element(std::forward(exec), ranges::begin(r), nth, ranges::end(r), + comp, proj); +\end{codeblock} +\end{itemdescr} + \rSec2[alg.binary.search]{Binary search} \rSec3[alg.binary.search.general]{General} @@ -7670,6 +9680,13 @@ template<@\libconcept{input_range}@ R, class Proj = identity, @\libconcept{indirect_unary_predicate}@, Proj>> Pred> constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + bool ranges::is_partitioned(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + bool ranges::is_partitioned(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7708,6 +9725,17 @@ requires @\libconcept{permutable}@> constexpr borrowed_subrange_t ranges::partition(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + subrange + // FIXME: LWG issue, I'm pretty sure there should be requires permutable here. + ranges::partition(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{permutable}@> + borrowed_subrange_t + ranges::partition(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7744,7 +9772,7 @@ Let $N = \tcode{last - first}$: \begin{itemize} \item - For the overload with no \tcode{ExecutionPolicy}, + For the non-parallel algorithm overloads, exactly $N$ applications of the predicate and projection. At most $N / 2$ swaps if the type of \tcode{first} meets the \oldconcept{BidirectionalIterator} requirements @@ -7753,7 +9781,7 @@ for the overloads in namespace \tcode{ranges}, and at most $N$ swaps otherwise. \item - For the overload with an \tcode{ExecutionPolicy}, + For the parallel algorithm overloads, \bigoh{N \log N} swaps and \bigoh{N} applications of the predicate. \end{itemize} @@ -7778,6 +9806,17 @@ @\libconcept{indirect_unary_predicate}@, Proj>> Pred> requires @\libconcept{permutable}@> constexpr borrowed_subrange_t ranges::stable_partition(R&& r, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{permutable}@ + subrange + ranges::stable_partition(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{permutable}@> + borrowed_subrange_t + ranges::stable_partition(Ep&& exec, R&& r, Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7819,11 +9858,12 @@ Let $N$ = \tcode{last - first}: \begin{itemize} \item - For the overloads with no \tcode{ExecutionPolicy}, at most $N \log_2 N$ swaps, + For the non-parallel algorithm overloads, + at most $N \log_2 N$ swaps, but only \bigoh{N} swaps if there is enough extra memory. Exactly $N$ applications of the predicate and projection. \item - For the overload with an \tcode{ExecutionPolicy}, + For the parallel algorithm overloads, \bigoh{N \log N} swaps and \bigoh{N} applications of the predicate. \end{itemize} \end{itemdescr} @@ -7854,6 +9894,25 @@ @\libconcept{indirectly_copyable}@, O2> constexpr ranges::partition_copy_result, O1, O2> ranges::partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + @\libconcept{random_access_iterator}@ O1, @\libconcept{sized_sentinel_for}@ OutS1, + @\libconcept{random_access_iterator}@ O2, @\libconcept{sized_sentinel_for}@ OutS2, + class Proj = identity, @\libconcept{indirect_unary_predicate}@> Pred> + requires @\libconcept{indirectly_copyable}@ && @\libconcept{indirectly_copyable}@ + ranges::partition_copy_result + ranges::partition_copy(Ep&& exec, I first, S last, O1 out_true, OutS1 last_true, + O2 out_false, OutS2 last_false, Pred pred, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + @\exposconcept{sized-random-access-range}@ OutR1, @\exposconcept{sized-random-access-range}@ OutR2, + class Proj = identity, + @\libconcept{indirect_unary_predicate}@, Proj>> Pred> + requires @\libconcept{indirectly_copyable}@, iterator_t> && + @\libconcept{indirectly_copyable}@, iterator_t> + ranges::partition_copy_result, borrowed_iterator_t, + borrowed_iterator_t> + ranges::partition_copy(Ep&& exec, R&& r, OutR1&& out_true_r, OutR2&& out_false_r, + Pred pred, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -7862,6 +9921,45 @@ for the overloads with no parameter named \tcode{proj} and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. +\pnum +For the overloads with no parameters +\tcode{last_true}, \tcode{last_false}, \tcode{out_true_r}, or \tcode{out_false_r}, +let +\begin{itemize} +\item + $M$ be the number of iterators in \range{first}{last} + for which $E(\tcode{i})$ is \tcode{true}, + and $K$ be \tcode{last - first}; +\item + \tcode{last_true} be \tcode{out_true + M}, and + \tcode{last_false} be \tcode{out_false + $K$}. +\end{itemize} + +\pnum +For the overloads with parameters +\tcode{last_true}, \tcode{last_false}, \tcode{out_true_r}, or \tcode{out_false_r}, +let $M$ be \tcode{last_true} \tcode{last_true - out_true} +and $K$ be \tcode{last_false - out_false}. + +\pnum +Let %FIXME: Colon. +\begin{itemize} +\item + \exposid{i1} be the iterator in \range{first}{last} + for which $E(\tcode{*i1})$ is \tcode{true} + and there are exactly $M$ iterators \tcode{j} in \range{first}{\exposid{i1}} + for which $E(\tcode{*j})$ is \tcode{true}, + or \tcode{last} if no such iterator exists; +\item + \exposid{i2} be the iterator in \range{first}{last} + for which $E(\tcode{*i2})$ is \tcode{false} + and there are exactly $K$ iterators \tcode{j} in \range{first}{\exposid{i2}} + for which $E(\tcode{*j})$ is \tcode{true}, + or \tcode{last} if no such iterator exists; +\item + $N$ be $\min(\tcode{\exposid{i1} - first}, \ \tcode{\exposid{i2} - first})$. +\end{itemize} + \pnum \mandates For the overloads in namespace \tcode{std}, @@ -7874,31 +9972,36 @@ The input range and output ranges do not overlap. \begin{note} -For the overload with an \tcode{ExecutionPolicy}, -there might be a performance cost if \tcode{first}'s value type +For the parallel algorithm overload in namespace \tcode{std}, +there can be a performance cost if \tcode{first}'s value type does not meet the \oldconcept{CopyConstructible} requirements. +For the parallel algorithm overloads in namespace \tcode{ranges}, +there can be a performance cost if \tcode{first}'s value type +does not model \libconcept{copy_constructible}. \end{note} \pnum \effects -For each iterator \tcode{i} in \range{first}{last}, -copies \tcode{*i} to the output range beginning with \tcode{out_true} +For each iterator \tcode{i} in \range{first}{first + $N$}, +copies \tcode{*i} to the output range \range{out_true}{last_true} if \tcode{$E(\tcode{*i})$} is \tcode{true}, or -to the output range beginning with \tcode{out_false} otherwise. +to the output range \range{out_false}{last_false} otherwise. \pnum \returns -Let \tcode{o1} be the end of the output range beginning at \tcode{out_true}, -and \tcode{o2} the end of the output range beginning at \tcode{out_false}. -Returns +Let \tcode{o1} be the iterator past the last copied element +in the output range \range{out_true}{last_true}, +and \tcode{o2} be the iterator past the last copied element +in the output range \range{out_false}{last_false}. +Returns: \begin{itemize} \item \tcode{\{o1, o2\}} for the overloads in namespace \tcode{std}. -\item \tcode{\{last, o1, o2\}} for the overloads in namespace \tcode{ranges}. +\item \tcode{\{first + $N$, o1, o2\}} for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -Exactly \tcode{last - first} applications of \tcode{pred} and \tcode{proj}. +At most \tcode{last - first} applications of \tcode{pred} and \tcode{proj}. \end{itemdescr} \indexlibraryglobal{partition_point}% @@ -7985,15 +10088,57 @@ constexpr ranges::merge_result, borrowed_iterator_t, O> ranges::merge(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + ranges::merge_result + ranges::merge(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, O result, OutS result_last, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, Comp, Proj1, Proj2> + ranges::merge_result, borrowed_iterator_t, borrowed_iterator_t> + ranges::merge(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} \pnum -Let $N$ be \tcode{(last1 - first1) + (last2 - first2)}. -Let \tcode{comp} be \tcode{less\{\}}, -\tcode{proj1} be \tcode{identity\{\}}, and -\tcode{proj2} be \tcode{identity\{\}}, -for the overloads with no parameters by those names. +Let: +\begin{itemize} +\item + $N$ be: + \begin{itemize} + \item + \tcode{(last1 - first1) + (last2 - first2)} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; + \item + $\min(\tcode{(last1 - first1) + (last2 - first2)}, \ \tcode{result_last - result})$ + for the overloads with parameters \tcode{result_last} or \tcode{result_r}; + \end{itemize} +\item + \tcode{comp} be \tcode{less\{\}}, + \tcode{proj1} be \tcode{identity\{\}}, and + \tcode{proj2} be \tcode{identity\{\}}, + for the overloads with no parameters by those names; +\item + $E$ be \tcode{bool(invoke(comp, invoke(proj2, e2), invoke(proj1, e1)))}; +\item + $K$ be the smallest integer in \range{0}{last1 - first1} + such that for every element \tcode{e1} in the position \tcode{first1 + $K$} + %FIXME: Comma. + there are at least $N - K$ elements \tcode{e2} + in \range{first2}{last2} for which $E$ holds, + and be equal to \tcode{last1 - first1} + if no such integer exists. + \begin{note} + \tcode{first1 + $K$} points to the position past the last element to be copied. + \end{note} +\end{itemize} \pnum \expects @@ -8004,25 +10149,24 @@ \pnum \effects -Copies all the elements of the two ranges \range{first1}{last1} and -\range{first2}{last2} into the range \range{result}{result_last}, -where \tcode{result_last} is \tcode{result + $N$}. +Copies the first $K$ elements of the range \range{first1}{last1} +and the first $N - K$ elements of the range \range{first2}{last2} +into the range \range{result}{result + $N$}. If an element \tcode{a} precedes \tcode{b} in an input range, \tcode{a} is copied into the output range before \tcode{b}. If \tcode{e1} is an element of \range{first1}{last1} and \tcode{e2} of \range{first2}{last2}, -\tcode{e2} is copied into the output range before \tcode{e1} if and only if -\tcode{bool(invoke(comp, invoke(proj2, e2), invoke(proj1, e1)))} -is \tcode{true}. +\tcode{e2} is copied into the output range before \tcode{e1} +if and only if $E$ is \tcode{true}. \pnum \returns \begin{itemize} \item - \tcode{result_last} + \tcode{result + $N$} for the overloads in namespace \tcode{std}. \item - \tcode{\{last1, last2, result_last\}} + \tcode{\{first1 + $K$, first2 + $N$ - $K$, result_last\}} for the overloads in namespace \tcode{ranges}. \end{itemize} @@ -8030,10 +10174,11 @@ \complexity \begin{itemize} \item - For the overloads with no \tcode{ExecutionPolicy}, + For the non-parallel algorithm overloads, at most $N - 1$ comparisons and applications of each projection. \item - For the overloads with an \tcode{ExecutionPolicy}, \bigoh{N} comparisons. + For the parallel algorithm overloads, + \bigoh{N} comparisons and applications of each projection. \end{itemize} \pnum @@ -8067,6 +10212,10 @@ class Proj = identity> requires @\libconcept{sortable}@ constexpr I ranges::inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Comp = ranges::less, class Proj = identity> + requires @\libconcept{sortable}@ + I ranges::inplace_merge(Ep&& exec, I first, I middle, S last, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -8102,7 +10251,7 @@ Let $N = \tcode{last - first}$: \begin{itemize} \item - For the overloads with no \tcode{ExecutionPolicy}, and + For the non-parallel algorithm overloads, and if enough additional memory is available, at most $N - 1$ comparisons. \item Otherwise, \bigoh{N \log N} comparisons. @@ -8130,6 +10279,25 @@ \end{codeblock} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Comp = ranges::less, + class Proj = identity> + requires @\libconcept{sortable}@, Comp, Proj> + borrowed_iterator_t + ranges::inplace_merge(Ep&& exec, R&& r, iterator_t middle, Comp comp = {}, + Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return ranges::inplace_merge(std::forward(exec), ranges::begin(r), middle, + ranges::end(r), comp, proj); +\end{codeblock} +\end{itemdescr} + \rSec2[alg.set.operations]{Set operations on sorted structures} \rSec3[alg.set.operations.general]{General} @@ -8177,6 +10345,20 @@ projected, Proj2>> Comp = ranges::less> constexpr bool ranges::includes(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, projected> Comp = + ranges::less> + bool ranges::includes(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, Proj1>, + projected, Proj2>> Comp = ranges::less> + bool ranges::includes(Ep&& exec, R1&& r1, R2&& r2, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -8250,13 +10432,44 @@ constexpr ranges::set_union_result, borrowed_iterator_t, O> ranges::set_union(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + ranges::set_union_result + ranges::set_union(Ep&& exec, I1 first1, S1 last1, + I2 first2, S2 last2, O result, OutS result_last, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + ranges::set_union_result, borrowed_iterator_t, + borrowed_iterator_t> + ranges::set_union(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{comp} be \tcode{less\{\}}, -and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} -for the overloads with no parameters by those names. +Let: +\begin{itemize} +\item + \tcode{comp} be \tcode{less\{\}}, + and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} + for the overloads with no parameters by those names; +\item + $M$ be \tcode{(last1 - first1)} plus the number elements in \range{first2}{last2} + that are not present in \range{first1}{last1}; +\item + \tcode{result_last} be \tcode{result + $M$} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(M, \ \tcode{result_last - result})$. +\end{itemize} \pnum \expects @@ -8266,20 +10479,25 @@ \pnum \effects -Constructs a sorted union of the elements from the two ranges; +Constructs a sorted union of $N$ elements from the two ranges; that is, the set of elements that are present in one or both of the ranges. \pnum \returns -Let \tcode{result_last} be the end of the constructed range. -Returns \begin{itemize} \item \tcode{result_last} for the overloads in namespace \tcode{std}. \item - \tcode{\{last1, last2, result_last\}} - for the overloads in namespace \tcode{ranges}. + \tcode{\{last1, last2, result + $N$\}} + for the overloads in namespace \tcode{ranges} + if $N$ is equal to $M$. +\item + Otherwise, \tcode{\{j1, j2, result_last\}} + for the overloads in namespace \tcode{ranges}, + where the iterators \tcode{j1} and \tcode{j2} + point to positions past the last copied or skipped elements + in \range{first1}{last1} and \range{first2}{last2}, respectively. \end{itemize} \pnum @@ -8345,13 +10563,44 @@ constexpr ranges::set_intersection_result, borrowed_iterator_t, O> ranges::set_intersection(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + ranges::set_intersection_result + ranges::set_intersection(Ep&& exec, I1 first1, S1 last1, + I2 first2, S2 last2, O result, OutS result_last, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + ranges::set_intersection_result, borrowed_iterator_t, + borrowed_iterator_t> + ranges::set_intersection(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{comp} be \tcode{less\{\}}, -and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} -for the overloads with no parameters by those names. +Let: +\begin{itemize} +\item + \tcode{comp} be \tcode{less\{\}}, + and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} + for the overloads with no parameters by those names; +\item + $M$ be \tcode{(last1 - first1)} plus the number elements in \range{first2}{last2} + that are not present in \range{first1}{last1}; +\item + \tcode{result_last} be \tcode{result + $M$} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(M, \ \tcode{result_last - result})$. +\end{itemize} \pnum \expects @@ -8361,20 +10610,25 @@ \pnum \effects -Constructs a sorted intersection of the elements from the two ranges; +Constructs a sorted intersection of $N$ elements from the two ranges; that is, the set of elements that are present in both of the ranges. \pnum \returns -Let \tcode{result_last} be the end of the constructed range. -Returns \begin{itemize} \item \tcode{result_last} for the overloads in namespace \tcode{std}. \item - \tcode{\{last1, last2, result_last\}} - for the overloads in namespace \tcode{ranges}. + \tcode{\{last1, last2, result + $N$\}} + for the overloads in namespace \tcode{ranges} + if $N$ is equal to $M$. +\item + Otherwise, \tcode{\{j1, j2, result_last\}} + for the overloads in namespace \tcode{ranges}, + where the iterators \tcode{j1} and \tcode{j2} + point to positions past the last copied or skipped elements + in \range{first1}{last1} and \range{first2}{last2}, respectively. \end{itemize} \pnum @@ -8438,13 +10692,44 @@ constexpr ranges::set_difference_result, O> ranges::set_difference(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + ranges::set_difference_result + ranges::set_difference(Ep&& exec, I1 first1, S1 last1, + I2 first2, S2 last2, O result, OutS result_last, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + ranges::set_difference_result, borrowed_iterator_t, + borrowed_iterator_t> + ranges::set_difference(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{comp} be \tcode{less\{\}}, -and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} -for the overloads with no parameters by those names. +Let: +\begin{itemize} +\item + \tcode{comp} be \tcode{less\{\}}, + and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} + for the overloads with no parameters by those names; +\item + $M$ be \tcode{(last1 - first1)} plus the number elements in \range{first2}{last2} + that are not present in \range{first1}{last1}; +\item + \tcode{result_last} be \tcode{result + $M$} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(M, \ \tcode{result_last - result})$. +\end{itemize} \pnum \expects @@ -8454,22 +10739,27 @@ \pnum \effects -Copies the elements of the range \range{first1}{last1} +Copies $N$ elements of the range \range{first1}{last1} which are not present in the range \range{first2}{last2} -to the range beginning at \tcode{result}. +to the range \range{result}{result + $N$}. The elements in the constructed range are sorted. \pnum \returns -Let \tcode{result_last} be the end of the constructed range. -Returns \begin{itemize} \item \tcode{result_last} for the overloads in namespace \tcode{std}. \item - \tcode{\{last1, result_last\}} - for the overloads in namespace \tcode{ranges}. + \tcode{\{last1, last2, result + $N$\}} + for the overloads in namespace \tcode{ranges} + if $N$ is equal to $M$. +\item + Otherwise, \tcode{\{j1, j2, result_last\}} + for the overloads in namespace \tcode{ranges}, + where the iterators \tcode{j1} and \tcode{j2} + point to positions past the last copied or skipped elements + in \range{first1}{last1} and \range{first2}{last2}, respectively. \end{itemize} \pnum @@ -8534,13 +10824,44 @@ borrowed_iterator_t, O> ranges::set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + @\libconcept{random_access_iterator}@ O, @\libconcept{sized_sentinel_for}@ OutS, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@ + ranges::set_symmetric_difference_result + ranges::set_symmetric_difference(Ep&& exec, I1 first1, S1 last1, + I2 first2, S2 last2, O result, OutS result_last, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + @\exposconcept{sized-random-access-range}@ OutR, class Comp = ranges::less, + class Proj1 = identity, class Proj2 = identity> + requires @\libconcept{mergeable}@, iterator_t, iterator_t, + Comp, Proj1, Proj2> + ranges::set_symmetric_difference_result, borrowed_iterator_t, + borrowed_iterator_t> + ranges::set_symmetric_difference(Ep&& exec, R1&& r1, R2&& r2, OutR&& result_r, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{comp} be \tcode{less\{\}}, -and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} -for the overloads with no parameters by those names. +Let: +\begin{itemize} +\item + \tcode{comp} be \tcode{less\{\}}, + and \tcode{proj1} and \tcode{proj2} be \tcode{identity\{\}} + for the overloads with no parameters by those names; +\item + $M$ be \tcode{(last1 - first1)} plus the number elements in \range{first2}{last2} + that are not present in \range{first1}{last1}; +\item + \tcode{result_last} be \tcode{result + $M$} + for the overloads with no parameter \tcode{result_last} or \tcode{result_r}; +\item + $N$ be $\min(M, \ \tcode{result_last - result})$. +\end{itemize} \pnum \expects @@ -8554,20 +10875,25 @@ that are not present in the range \range{first2}{last2}, and the elements of the range \range{first2}{last2} that are not present in the range \range{first1}{last1} -to the range beginning at \tcode{result}. +to the range \range{result}{result + $N$}. The elements in the constructed range are sorted. \pnum \returns -Let \tcode{result_last} be the end of the constructed range. -Returns \begin{itemize} \item \tcode{result_last} for the overloads in namespace \tcode{std}. \item - \tcode{\{last1, last2, result_last\}} - for the overloads in namespace \tcode{ranges}. + \tcode{\{last1, last2, result + $N$\}} + for the overloads in namespace \tcode{ranges} + if $N$ is equal to $M$. +\item + Otherwise, \tcode{\{j1, j2, result_last\}} + for the overloads in namespace \tcode{ranges}, + where the iterators \tcode{j1} and \tcode{j2} + point to positions past the last copied or skipped elements + in \range{first1}{last1} and \range{first2}{last2}, respectively. \end{itemize} \pnum @@ -8910,6 +11236,25 @@ \tcode{return ranges::is_heap_until(first, last, comp, proj) == last;} \end{itemdescr} +\begin{itemdecl} +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + bool ranges::is_heap(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + bool ranges::is_heap(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return ranges::is_heap_until(std::forward(exec), first, last, comp, proj) == last; +\end{codeblock} +\end{itemdescr} + \indexlibraryglobal{is_heap_until}% \begin{itemdecl} template @@ -8937,6 +11282,15 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t ranges::is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I ranges::is_heap_until(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + ranges::is_heap_until(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -9008,6 +11362,11 @@ requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> constexpr range_value_t ranges::min(R&& r, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> + range_value_t + ranges::min(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -9086,6 +11445,11 @@ requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> constexpr range_value_t ranges::max(R&& r, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> + range_value_t + ranges::max(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -9167,6 +11531,11 @@ requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> constexpr ranges::minmax_result> ranges::minmax(R&& r, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + requires @\libconcept{indirectly_copyable_storable}@, range_value_t*> + ranges::minmax_result> + ranges::minmax(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -9222,6 +11591,16 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t ranges::min_element(R&& r, Comp comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I ranges::min_element(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + ranges::min_element(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -9269,6 +11648,16 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + I ranges::max_element(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + borrowed_iterator_t + ranges::max_element(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} \begin{itemdescr} @@ -9319,6 +11708,16 @@ @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> constexpr ranges::minmax_element_result> ranges::minmax_element(R&& r, Comp comp = {}, Proj proj = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S, + class Proj = identity, + @\libconcept{indirect_strict_weak_order}@> Comp = ranges::less> + ranges::minmax_element_result + ranges::minmax_element(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R, class Proj = identity, + @\libconcept{indirect_strict_weak_order}@, Proj>> Comp = ranges::less> + ranges::minmax_element_result> + ranges::minmax_element(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {}); \end{itemdecl} @@ -9427,6 +11826,20 @@ constexpr bool ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + +template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I1, @\libconcept{sized_sentinel_for}@ S1, + @\libconcept{random_access_iterator}@ I2, @\libconcept{sized_sentinel_for}@ S2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, + projected> Comp = ranges::less> + bool ranges::lexicographical_compare(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); +template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ R1, @\exposconcept{sized-random-access-range}@ R2, + class Proj1 = identity, class Proj2 = identity, + @\libconcept{indirect_strict_weak_order}@, Proj1>, + projected, Proj2>> Comp = ranges::less> + bool ranges::lexicographical_compare(Ep&& exec, R1&& r1, R2&& r2, Comp comp = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); \end{itemdecl} \begin{itemdescr} @@ -11218,6 +13631,26 @@ \end{note} \end{itemdescr} +\begin{itemdecl} +template +concept @\defexposconcept{nothrow-sized-sentinel-for}@ = // \expos + @\exposconcept{nothrow-sentinel-for}@ && + @\libconcept{sentinel_for}@; +\end{itemdecl} + +\begin{itemdescr} +\pnum +Types \tcode{S} and \tcode{I} model \exposconcept{nothrow-sized-sentinel-for} +only if no exceptions are thrown from the \tcode{-} operator +for valid values of type \tcode{I} and \tcode{S}. + +\pnum +\begin{note} +This concept allows some \libconcept{sized_sentinel_for}\iref{iterator.concept.sizedsentinel} +operations to throw exceptions. +\end{note} +\end{itemdescr} + \begin{itemdecl} template concept @\defexposconcept{nothrow-input-range}@ = // \expos @@ -11256,6 +13689,68 @@ @\exposconcept{nothrow-forward-iterator}@>; \end{itemdecl} +\begin{itemdecl} +template +concept @\defexposconcept{nothrow-bidirectional-iterator}@ = // \expos + @\exposconcept{nothrow-forward-iterator}@ && + @\libconcept{bidirectional_iterator}@; +\end{itemdecl} + +\begin{itemdescr} +\pnum +A type \tcode{I} models \exposconcept{nothrow-bidirectional-iterator} +only if no exceptions are thrown from decrementing valid iterators. +\begin{note} +This concept allows some \libconcept{bidirectional_iterator}\iref{iterator.concept.bidir} +operations to throw exceptions. +\end{note} +\end{itemdescr} + +\begin{itemdecl} +template +concept @\defexposconcept{nothrow-bidirectional-range}@ = // \expos + @\exposconcept{nothrow-forward-range}@ && + @\exposconcept{nothrow-bidirectional-iterator}@>; +\end{itemdecl} + +\begin{itemdecl} +template +concept @\defexposconcept{nothrow-random-access-iterator}@ = // \expos + @\exposconcept{nothrow-bidirectional-iterator}@ && + @\libconcept{random_access_iterator}@ && + @\exposconcept{nothrow-sized-sentinel-for}@; +\end{itemdecl} + +\begin{itemdescr} +\pnum +A type \tcode{I} models \exposconcept{nothrow-random-access-iterator} +only if no exceptions are thrown from comparisons of valid iterators, +or the \tcode{-}, \tcode{+}, \tcode{-=}, \tcode{+=}, \tcode{[]} operators +on valid values of type \tcode{I} and \tcode{iter_difference_t}. +\begin{note} +This concept allows some \libconcept{random_access_iterator}\iref{iterator.concept.random.access} +operations to throw exceptions. +\end{note} +\end{itemdescr} + +\begin{itemdecl} +template +concept @\defexposconcept{nothrow-random-access-range}@ = // \expos + @\exposconcept{nothrow-bidirectional-range}@ && + @\exposconcept{nothrow-random-access-iterator}@>; + +template +concept @\defexposconcept{nothrow-sized-random-access-range}@ = // \expos + @\exposconcept{nothrow-random-access-range}@ && @\libconcept{sized_range}@; +\end{itemdecl} + +\begin{itemdescr} +\pnum +A type \tcode{R} models \exposconcept{nothrow-sized-random-access-range} +only if no exceptions are thrown from the call to \tcode{ranges::size} +on an object of type \tcode{R}. +\end{itemdescr} + \rSec2[uninitialized.construct.default]{\tcode{uninitialized_default_construct}} \indexlibraryglobal{uninitialized_default_construct}% diff --git a/source/memory.tex b/source/memory.tex index d4451b0201..ae9521a3fb 100644 --- a/source/memory.tex +++ b/source/memory.tex @@ -181,15 +181,27 @@ // \ref{specialized.algorithms}, specialized algorithms // \ref{special.mem.concepts}, special memory concepts template - concept @\exposconcept{nothrow-input-iterator}@ = @\seebelow@; // \expos + concept @\exposconcept{nothrow-input-iterator}@ = @\seebelow@; // \expos template - concept @\exposconcept{nothrow-forward-iterator}@ = @\seebelow@; // \expos + concept @\exposconcept{nothrow-forward-iterator}@ = @\seebelow@; // \expos + template + concept @\exposconcept{nothrow-bidirectional-iterator}@ = @\seebelow@; // \expos + template + concept @\exposconcept{nothrow-random-access-iterator}@ = @\seebelow@; // \expos + template + concept @\exposconcept{nothrow-sentinel-for}@ = @\seebelow@; // \expos template - concept @\exposconcept{nothrow-sentinel-for}@ = @\seebelow@; // \expos + concept @\exposconcept{nothrow-sized-sentinel-for}@ = @\seebelow@; // \expos + template + concept @\exposconcept{nothrow-input-range}@ = @\seebelow@; // \expos + template + concept @\exposconcept{nothrow-forward-range}@ = @\seebelow@; // \expos template - concept @\exposconcept{nothrow-input-range}@ = @\seebelow@; // \expos + concept @\exposconcept{nothrow-bidirectional-range}@ = @\seebelow@; // \expos template - concept @\exposconcept{nothrow-forward-range}@ = @\seebelow@; // \expos + concept @\exposconcept{nothrow-random-access-range}@ = @\seebelow@; // \expos + template + concept @\exposconcept{nothrow-sized-random-access-range}@ = @\seebelow@; // \expos template constexpr void uninitialized_default_construct(NoThrowForwardIterator first, // freestanding @@ -219,6 +231,21 @@ requires @\libconcept{default_initializable}@> constexpr I uninitialized_default_construct_n(I first, // freestanding iter_difference_t n); + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@ S> + requires @\libconcept{default_initializable}@> + I uninitialized_default_construct(Ep&& exec, // freestanding-deleted, + I first, S last); // see \ref{algorithms.parallel.overloads} + %FIXME: weird gap, probably unintentional + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-sized-random-access-range}@ R> + requires @\libconcept{default_initializable}@> + borrowed_iterator_t uninitialized_default_construct(Ep&& exec, // freestanding-deleted, + R&& r); // see \ref{algorithms.parallel.overloads} + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I> + requires @\libconcept{default_initializable}@> + I uninitialized_default_construct_n(Ep&& exec, I first, // freestanding-deleted, + iter_difference_t n); // see \ref{algorithms.parallel.overloads} } template @@ -249,6 +276,20 @@ requires @\libconcept{default_initializable}@> constexpr I uninitialized_value_construct_n(I first, // freestanding iter_difference_t n); + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@ S> + requires @\libconcept{default_initializable}@> + I uninitialized_value_construct(Ep&& exec, // freestanding-deleted, + I first, S last); // see \ref{algorithms.parallel.overloads} + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-sized-random-access-range}@ R> + requires @\libconcept{default_initializable}@> + borrowed_iterator_t uninitialized_value_construct(Ep&& exec, // freestanding-deleted, + R&& r); // see \ref{algorithms.parallel.overloads} + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I> + requires @\libconcept{default_initializable}@> + I uninitialized_value_construct_n(Ep&& exec, I first, // freestanding-deleted, + iter_difference_t n); // see \ref{algorithms.parallel.overloads} } template @@ -291,6 +332,26 @@ constexpr uninitialized_copy_n_result uninitialized_copy_n(I ifirst, iter_difference_t n, // freestanding O ofirst, S olast); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S1, + @\exposconcept{nothrow-random-access-iterator}@ O, @\exposconcept{nothrow-sentinel-for}@ S2> + requires @\libconcept{constructible_from}@, iter_reference_t> + uninitialized_copy_result + uninitialized_copy(Ep&& exec, I ifirst, S1 ilast, // freestanding-deleted, + O ofirst, S2 olast); // see \ref{algorithms.parallel.overloads} + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ IR, + @\exposconcept{nothrow-sized-random-access-range}@ OR> + requires @\libconcept{constructible_from}@, range_reference_t> + uninitialized_copy_result, borrowed_iterator_t> + uninitialized_copy(Ep&& exec, IR&& in_range, // freestanding-deleted, + OR&& out_range); // see \ref{algorithms.parallel.overloads} + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\exposconcept{nothrow-random-access-iterator}@ O, + @\exposconcept{nothrow-sentinel-for}@ S> + requires @\libconcept{constructible_from}@, iter_reference_t> + uninitialized_copy_n_result + uninitialized_copy_n(Ep&& exec, I ifirst, iter_difference_t n, // freestanding-deleted, + O ofirst, S olast); // see \ref{algorithms.parallel.overloads} } template @@ -334,6 +395,26 @@ constexpr uninitialized_move_n_result uninitialized_move_n(I ifirst, iter_difference_t n, // freestanding O ofirst, S olast); + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, @\libconcept{sized_sentinel_for}@ S1, + @\exposconcept{nothrow-random-access-iterator}@ O, @\exposconcept{nothrow-sentinel-for}@ S2> + requires @\libconcept{constructible_from}@, iter_rvalue_reference_t> + uninitialized_move_result + uninitialized_move(Ep&& exec, I ifirst, S1 ilast, // freestanding-deleted, + O ofirst, S2 olast); // see \ref{algorithms.parallel.overloads} + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{sized-random-access-range}@ IR, + @\exposconcept{nothrow-sized-random-access-range}@ OR> + requires @\libconcept{constructible_from}@, range_rvalue_reference_t> + uninitialized_move_result, borrowed_iterator_t> + uninitialized_move(Ep&& exec, IR&& in_range, // freestanding-deleted, + OR&& out_range); // see \ref{algorithms.parallel.overloads} + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{random_access_iterator}@ I, + @\exposconcept{nothrow-random-access-iterator}@ O, @\exposconcept{nothrow-sentinel-for}@ S> + requires @\libconcept{constructible_from}@, iter_rvalue_reference_t> + uninitialized_move_n_result + uninitialized_move_n(Ep&& exec, I ifirst, iter_difference_t n, // freestanding-deleted, + O ofirst, S olast); // see \ref{algorithms.parallel.overloads} } template @@ -365,6 +446,21 @@ requires @\libconcept{constructible_from}@, const T&> constexpr I uninitialized_fill_n(I first, // freestanding iter_difference_t n, const T& x); + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@ S, + class T> + requires @\libconcept{constructible_from}@, const T&> + I uninitialized_fill(Ep&& exec, I first, S last, // freestanding-deleted, + const T& x); // see \ref{algorithms.parallel.overloads} + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-sized-random-access-range}@ R, class T> + requires @\libconcept{constructible_from}@, const T&> + borrowed_iterator_t uninitialized_fill(Ep&& exec, R&& r, // freestanding-deleted, + const T& x); // see \ref{algorithms.parallel.overloads} + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I, class T> + requires @\libconcept{constructible_from}@, const T&> + I uninitialized_fill_n(Ep&& exec, I first, // freestanding-deleted, + iter_difference_t n, const T& x); // see \ref{algorithms.parallel.overloads} } // \ref{specialized.construct}, \tcode{construct_at} @@ -407,6 +503,23 @@ template<@\exposconcept{nothrow-input-iterator}@ I> requires @\libconcept{destructible}@> constexpr I destroy_n(I first, iter_difference_t n) noexcept; // freestanding + + template<@\exposconcept{execution-policy}@ Ep, @\libconcept{destructible}@ T> + void destroy_at(Ep&& exec, T* location) noexcept; // freestanding-deleted + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@ S> + requires @\libconcept{destructible}@> + I destroy(Ep&& exec, // freestanding-deleted, + I first, S last) noexcept; // see \ref{algorithms.parallel.overloads} + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-sized-random-access-range}@ R> + requires @\libconcept{destructible}@> + borrowed_iterator_t destroy(Ep&& exec, // freestanding-deleted, + R&& r) noexcept; // see \ref{algorithms.parallel.overloads} + + template<@\exposconcept{execution-policy}@ Ep, @\exposconcept{nothrow-random-access-iterator}@ I> + requires @\libconcept{destructible}@> + I destroy_n(Ep&& exec, I first, // freestanding-deleted, + iter_difference_t n) noexcept; // see \ref{algorithms.parallel.overloads} } // \ref{unique.ptr}, class template \tcode{unique_ptr} diff --git a/source/ranges.tex b/source/ranges.tex index c16eba7f10..baace89600 100644 --- a/source/ranges.tex +++ b/source/ranges.tex @@ -132,6 +132,10 @@ template concept constant_range = @\seebelow@; + %FIXME: Shouldn't this be under [range.sized] ?! + template + concept @\defexposconcept{sized-random-access-range}@ = @\seebelow@; // \expos + // \ref{view.interface}, class template \tcode{view_interface} template requires is_class_v && @\libconcept{same_as}@> @@ -1721,6 +1725,21 @@ @\libconcept{input_range}@ && @\exposconcept{constant-iterator}@>; \end{itemdecl} +\pnum +The exposition-only concept \exposconcept{sized-random-access-range} +specifies the requirements of a \libconcept{range} type +that is sized and allows random access to its elements. + +\begin{itemdecl} +template + concept @\defexposconcept{sized-random-access-range}@ = // \expos + @\libconcept{random_access_range}@ && @\libconcept{sized_range}@; +\end{itemdecl} +\begin{note} +This concept constrains some parallel algorithm overloads; +see \ref{algorithms}. +\end{note} + \rSec1[range.utility]{Range utilities} \rSec2[range.utility.general]{General} diff --git a/source/support.tex b/source/support.tex index 95d674aafb..cefdfef960 100644 --- a/source/support.tex +++ b/source/support.tex @@ -755,7 +755,8 @@ #define @\defnlibxname{cpp_lib_optional}@ 202110L // also in \libheader{optional} #define @\defnlibxname{cpp_lib_optional_range_support}@ 202406L // freestanding, also in \libheader{optional} #define @\defnlibxname{cpp_lib_out_ptr}@ 202311L // freestanding, also in \libheader{memory} -#define @\defnlibxname{cpp_lib_parallel_algorithm}@ 201603L // also in \libheader{algorithm}, \libheader{numeric} +#define @\defnlibxname{cpp_lib_parallel_algorithm}@ 202506L + // also in \libheader{algorithm}, \libheader{numeric}, \libheader{memory} #define @\defnlibxname{cpp_lib_philox_engine}@ 202406L // also in \libheader{random} #define @\defnlibxname{cpp_lib_polymorphic}@ 202502L // also in \libheader{memory} #define @\defnlibxname{cpp_lib_polymorphic_allocator}@ 201902L // also in \libheader{memory_resource}