This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4516. ranges namespace is used inconsistently in [algorithms]

Section: 26 [algorithms] Status: New Submitter: Ruslan Arutyunyan Opened: 2025-12-12 Last modified: 2026-02-01

Priority: Not Prioritized

View other active issues in [algorithms].

View all other issues in [algorithms].

View all issues with New status.

Discussion:

ranges namespace is used inconsistently in 26 [algorithms]. One example is:

template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  requires sortable<iterator_t<R>, Comp, Proj>
  constexpr borrowed_iterator_t<R>
    ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {});

where we can see ranges:: before push_heap name itself, also before less but not before random_access_range. It's all over the place. The same is with sort:

template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  requires sortable<iterator_t<R>, Comp, Proj>
  constexpr borrowed_iterator_t<R>
    ranges::sort(R&& r, Comp comp = {}, Proj proj = {});

Another example is for_each where we don't have ranges namespace before borrowed_iterator_t:

template<input_range R, class Proj = identity,
         indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
  constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
    ranges::for_each(R&& r, Fun f, Proj proj = {});

There is no clear resolution for that, but during an LWG session is was decided to create an LWG issue for this.

Proposed resolution: