Title
§[alg.partitions] Clarify Returns: element
Status
wp
Section
[alg.partitions]
Submitter
Ruslan Arutyunyan

Created on 2025-11-07.00:00:00 last changed 1 week ago

Messages

Date: 2025-11-11.10:48:55

Proposed resolution:

This wording is relative to N5014.

  1. Modify [alg.partitions], as indicated:

    template<class InputIterator, class OutputIterator1, class OutputIterator2, class Predicate>
      constexpr pair<OutputIterator1, OutputIterator2>
        partition_copy(InputIterator first, InputIterator last,
                       OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred);
    […]
    template<execution-policy Ep, sized-random-access-range R,
             sized-random-access-range OutR1, sized-random-access-range OutR2,
             class Proj = identity,
             indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
      requires indirectly_copyable<iterator_t<R>, iterator_t<OutR1>> &&
                indirectly_copyable<iterator_t<R>, iterator_t<OutR2>>
      ranges::partition_copy_result<borrowed_iterator_t<R>, borrowed_iterator_t<OutR1>,
                                    borrowed_iterator_t<OutR2>>
        ranges::partition_copy(Ep&& exec, R&& r, OutR1&& out_true_r, OutR2&& out_false_r,
                               Pred pred, Proj proj = {});
    

    -14- Let `proj` be `identity{}` for the overloads with no parameter named `proj` and let E(x) be bool(invoke(pred, invoke(proj, x))).

    […]

    -19- Preconditions: The input range and output ranges do not overlap. […]

    -20- Effects: For each iterator `i` in [first, first + N), copies `*i` to the output range `[out_true, last_true)` if E(*i) is `true`, or to the output range `[out_false, last_false)` otherwise.

    -21- Returns: Let `o1` Q be the iterator past the last number of elements copied element into the output range `[out_true, last_true)`, and `o2` V be the iterator past the last number of elements copied element into the output range `[out_false, last_false)`. Returns:

    • (21.1) — {o1out_true + Q, o2out_false + V} for the overloads in namespace `std`.
    • (21.2) — {first + N, o1out_true + Q, o2out_false + V} for the overloads in namespace `ranges`.

    -22- Complexity: At `most last - first` applications of `pred` and `proj`.

Date: 2025-11-11.10:48:55

[ Kona 2025-11-08; Status changed: Immediate → WP. ]

Date: 2025-11-08.01:44:36

[ Kona 2025-11-07; approved by LWG. Status changed: New → Immediate. ]

Date: 2025-11-08.01:31:44
Addresses US 162-261

In [alg.partitions] p21 the wording is unclear what happens if there is no such element. The proposed resolution tries to clarify that without complicating the wording. If the proposed resolution (or something along those lines) fails, the recommendation is to reject US 162-261.

History
Date User Action Args
2025-11-11 10:48:55adminsetmessages: + msg15713
2025-11-11 10:48:55adminsetstatus: immediate -> wp
2025-11-08 01:44:36adminsetmessages: + msg15602
2025-11-08 01:44:36adminsetstatus: new -> immediate
2025-11-07 18:09:18adminsetmessages: + msg15589
2025-11-07 00:00:00admincreate