Title
Missing `permutable` constraint for iterator overloads in Parallel Range Algorithms
Status
new
Section
[algorithm.syn][alg.remove][alg.partitions]
Submitter
Ruslan Arutyunyan

Created on 2025-06-27.00:00:00 last changed 1 month ago

Messages

Date: 2025-08-16.09:29:49

Proposed resolution:

This wording is relative to N5014.

  1. Modify [algorithm.syn], header <algorithm>, as indicated:

    […]
    template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
             class Proj = identity, class T = projected_value_t<I, Proj>>
      requires permutable<I> &&
               indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
      subrange<I> remove(Ep& exec, I first, S last, const T& value,
                         Proj proj = {}); // freestanding-deleted
    template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
             class T = projected_value_t<iterator_t<R>, Proj>>
      requires permutable<iterator_t<R>> &&
               indirect_binary_predicate<ranges::equal_to,
                                         projected<iterator_t<R>, Proj>, const T*>
      borrowed_subrange_t<R>
        remove(Ep&& exec, R&& r, const T& value, Proj proj = {}); // freestanding-deleted                                     
    […]
    template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
             class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
      requires permutable<I>
      subrange<I>
        remove_if(Ep& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted
    template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
             indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
      requires permutable<iterator_t<R>>
      borrowed_subrange_t<R>
        remove_if(Ep& exec, R& r, Pred pred, Proj proj = {}); // freestanding-deleted
    […]
    template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
             class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
      requires permutable<I>
      subrange<I>
        partition(Ep&& exec, I first, S last, Pred pred, Proj proj = {}); // freestanding-deleted
    template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
             indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
      requires permutable<iterator_t<R>>
      borrowed_subrange_t<R>
        partition(Ep&& exec, R&& r, Pred pred, Proj proj = {}); // freestanding-deleted
    […]
    
  2. Modify [alg.remove] as indicated:

    […]
    template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
             class Proj = identity, class T = projected_value_t<I, Proj>>
      requires permutable<I> &&
               indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
      subrange<I> 
        ranges::remove(Ep& exec, I first, S last, const T& value, Proj proj = {});
    template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
             class T = projected_value_t<iterator_t<R>, Proj>>
      requires permutable<iterator_t<R>> &&
               indirect_binary_predicate<ranges::equal_to,
                                         projected<iterator_t<R>, Proj>, const T*>
      borrowed_subrange_t<R>
        ranges::remove(Ep&& exec, R&& r, const T& value, Proj proj = {});                                  
    […]
    template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
             class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
      requires permutable<I>
      subrange<I>
        ranges::remove_if(Ep& exec, I first, S last, Pred pred, Proj proj = {});
    template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
             indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
      requires permutable<iterator_t<R>>
      borrowed_subrange_t<R>
        ranges::remove_if(Ep& exec, R& r, Pred pred, Proj proj = {});
    

    -1- Let E be […]

  3. Modify [alg.partitions] as indicated:

    […]
    template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
             class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
      requires permutable<I>
      subrange<I>
        ranges::partition(Ep&& exec, I first, S last, Pred pred, Proj proj = {});
    template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
             indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
      requires permutable<iterator_t<R>>
      borrowed_subrange_t<R>
        ranges::partition(Ep&& exec, R&& r, Pred pred, Proj proj = {});
    

    -1- Let `proj` be `identity{}` for the overloads with no parameter named `proj`.

Date: 2025-06-27.00:00:00

The P3179R9: Parallel Range Algorithms paper was accepted to C++ working draft for C++ 26. Unfortunately, there is an oversight for three algorithms — `remove`, `remove_if` and `partition` — where the `permutable` constraint is missing. This applies to "Iterator and Sentinel" overloads only. The issue exists in [algorithm.syn] as well as in per-algorithm sections: [alg.partitions] and [alg.remove].

History
Date User Action Args
2025-07-26 12:00:59adminsetmessages: + msg14901
2025-06-27 00:00:00admincreate