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.

3873. join_with_view's const begin is underconstrained

Section: 26.7.15.2 [range.join.with.view] Status: New Submitter: Hewill Kang Opened: 2023-02-04 Last modified: 2023-02-10

Priority: 3

View all issues with New status.

Discussion:

In order to ensure that the pattern range is compatible with the inner range, join_with_view requires that the two range types must satisfy compatible-joinable-ranges, which requires that the value type, reference type, and rvalue reference type of the two range types share a common type.

However, when the two range types are const-qualified, there is no guarantee that their common reference type still exists, in which case a hard error may occur since join_with_view's const begin does not check for this (online example):

#include <ranges>

struct S {
  S(const int&);
  S(int&&);
  S(const int&&) = delete;
};

int main() {
  const auto r = std::views::single(std::views::single(0))
               | std::views::join_with(std::views::single(S{0}));
  auto e = std::ranges::iter_move(r.begin()); // hard error
}

[Issaquah 2023-02-10; LWG issue processing]

Set priority to 3.

Proposed resolution: