Title
join_with_view's const begin is underconstrained
Status
new
Section
[range.join.with.view]
Submitter
Hewill Kang

Created on 2023-02-04.00:00:00 last changed 22 months ago

Messages

Date: 2023-02-10.17:52:15

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

Set priority to 3.

Date: 2023-02-04.00:00:00

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
}
History
Date User Action Args
2023-02-10 17:52:15adminsetmessages: + msg13337
2023-02-04 00:00:00admincreate