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

3860. range_common_reference_t is missing

Section: 26.2 [ranges.syn] Status: C++23 Submitter: Hewill Kang Opened: 2023-01-24 Last modified: 2023-11-22

Priority: Not Prioritized

View other active issues in [ranges.syn].

View all other issues in [ranges.syn].

View all issues with C++23 status.

Discussion:

For the alias template iter_meow_t in <iterator>, there are almost all corresponding range_meow_t in <ranges>, except for iter_common_reference_t, which is used to calculate the common reference type shared by reference and value_type of the iterator.

Given that it has a highly similar formula form to iter_const_reference_t, and the latter has a corresponding sibling, I think we should add a range_common_reference_t for <ranges>.

This increases the consistency of the two libraries and simplifies the text of getting common reference from a range. Since C++23 brings proxy iterators and tuple enhancements, I believe such introduction can bring some value.

[2023-02-06; Reflector poll]

Set status to Tentatively Ready after seven votes in favour during reflector poll.

[2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4928.

  1. Modify 26.2 [ranges.syn], header <ranges> synopsis, as indicated:

    #include <compare>              // see 17.11.1 [compare.syn]
    #include <initializer_list>     // see 17.10.2 [initializer.list.syn]
    #include <iterator>             // see 25.2 [iterator.synopsis]
    
    namespace std::ranges {
      […]
      template<range R>
        using range_reference_t = iter_reference_t<iterator_t<R>>;                      // freestanding
      template<range R>
        using range_const_reference_t = iter_const_reference_t<iterator_t<R>>;          // freestanding
      template<range R>
        using range_rvalue_reference_t = iter_rvalue_reference_t<iterator_t<R>>;        // freestanding
      template<range R>
        using range_common_reference_t = iter_common_reference_t<iterator_t<R>>;        // freestanding
      […]
    }