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.

3729. std::tuple_element_t<std::ranges::subrange<I, S, K>> should remove top-level cv-qualifiers

Section: 25.2 [ranges.syn] Status: New Submitter: Jiang An Opened: 2022-06-30 Last modified: 2022-07-08

Priority: 4

View all other issues in [ranges.syn].

View all issues with New status.

Discussion:

std::ranges::subrange<int * volatile>> is weird but valid. The return type (deduced type for auto) of std::ranges::get for this type is int*, because the replacing of that (cv-unqualified) auto drops top-level cv-qualifiers. I think get is doing the right thing, and std::tuple_element_t should be consistent with the return types.

[2022-07-08; Reflector poll]

Set priority to 4 after reflector poll. "This is just contrived, especially since lots of the iterator requirements on such a type involve deprecated operations."

Proposed resolution:

This wording is relative to N4910.

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

    […]
    namespace std {
      […]
      
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<0, ranges::subrange<I, S, K>> {
        using type = remove_cv_t<I>;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<1, ranges::subrange<I, S, K>> {
        using type = remove_cv_t<S>;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<0, const ranges::subrange<I, S, K>> {
        using type = remove_cv_t<I>;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<1, const ranges::subrange<I, S, K>> {
        using type = remove_cv_t<S>;
      };
    }
    […]