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

3323. has-tuple-element helper concept needs convertible_to

Section: 25.7.23.2 [range.elements.view] Status: C++20 Submitter: Great Britain Opened: 2019-11-06 Last modified: 2021-02-25

Priority: 0

View all other issues in [range.elements.view].

View all issues with C++20 status.

Discussion:

Addresses GB 299

has-tuple-element helper concept needs convertible_to

The exposition-only has-tuple-element concept (for elements_view) is defined as

template<class T, size_t N>
concept has-tuple-element = exposition only
  requires(T t) {
    typename tuple_size<T>::type;
    requires N < tuple_size_v<T>;
    typename tuple_element_t<N, T>;
    { get<N>(t) } -> const tuple_element_t<N, T>&;
  };

However, the return type constraint for { get<N>(t) } is no longer valid under the latest concepts changes

Proposed change:

Change to:

template<class T, size_t N>
concept has-tuple-element = exposition only
  requires(T t) {
    typename tuple_size<T>::type;
    requires N < tuple_size_v<T>;
    typename tuple_element_t<N, T>;
    { get<N>(t) } -> convertible_to<const tuple_element_t<N, T>&>;
  };

Jonathan Wakely:

The NB comment says "The return type constraint for { get(t) } is no longer valid under the latest concepts changes." The changes referred to are those in P1452R2.

[2019-11 Status to Ready during Wednesday night issue processing in Belfast.]

Proposed resolution:

This wording is relative to N4835.

  1. Modify 25.7.23.2 [range.elements.view], class template elements_view synopsis, as indicated:

    namespace std::ranges {
      template<class T, size_t N>
      concept has-tuple-element = // exposition only
        requires(T t) {
          typename tuple_size<T>::type;
          requires N < tuple_size_v<T>;
          typename tuple_element_t<N, T>;
          { get<N>(t) } -> convertible_to<const tuple_element_t<N, T>&>;
        };
    […]
    }