Title
tuple_element_t is also wrong for const subrange
Status
c++20
Section
[ranges.syn]
Submitter
Casey Carter

Created on 2019-02-13.00:00:00 last changed 45 months ago

Messages

Date: 2020-02-14.16:06:37

Proposed resolution:

This wording is relative to N4849.

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

    […]
    namespace std {
      namespace views = ranges::views;
    
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_size<ranges::subrange<I, S, K>>
        : integral_constant<size_t, 2> {};
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<0, ranges::subrange<I, S, K>> {
        using type = I;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<1, ranges::subrange<I, S, K>> {
        using type = S;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<0, const ranges::subrange<I, S, K>> {
        using type = I;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<1, const ranges::subrange<I, S, K>> {
        using type = S;
      };
    }
    
Date: 2020-02-15.00:00:00

[ 2020-02-14, Prague ]

LWG decided to remove the volatile support, we shouldn't give the impression to support an idiom that wouldn't work.

Date: 2020-02-14.16:06:37

As currently specified, it uses the cv-qualified partial specialization, which incorrectly adds cv-qualification to the element type.

Previous resolution [SUPERSEDED]:

This wording is relative to N4849.

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

    […]
    namespace std {
      namespace views = ranges::views;
    
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_size<ranges::subrange<I, S, K>>
        : integral_constant<size_t, 2> {};
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<0, ranges::subrange<I, S, K>> {
        using type = I;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<1, ranges::subrange<I, S, K>> {
        using type = S;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<0, const ranges::subrange<I, S, K>> {
        using type = I;
      };
      template<class I, class S, ranges::subrange_kind K>
      struct tuple_element<1, const ranges::subrange<I, S, K>> {
        using type = S;
      };
    }
    
  2. Add the following wording to Annex D:

    D.? Deprecated subrange tuple interface [depr.ranges.syn]

    1 The header <ranges> ([ranges.syn]) has the following additions:

    namespace std {
      template<size_t X, class I, class S, ranges::subrange_kind K>
      struct tuple_element<X, volatile ranges::subrange<I, S, K>> {};
      template<size_t X, class I, class S, ranges::subrange_kind K>
      struct tuple_element<X, const volatile ranges::subrange<I, S, K>> {};
    }
    
History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-14 16:06:37adminsetmessages: + msg11131
2020-02-14 16:06:37adminsetstatus: new -> immediate
2020-02-13 21:09:02adminsetmessages: + msg11086
2019-02-13 00:00:00admincreate