3971. Join ranges of rvalue references with ranges of prvalues

Section: 26.7.15.2 [range.join.with.view] Status: SG9 Submitter: Hewill Kang Opened: 2023-08-21 Last modified: 2023-10-30 16:39:42 UTC

Priority: 3

View other active issues in [range.join.with.view].

View all other issues in [range.join.with.view].

Discussion:

The issue that concat_view implicitly breaks equality-preserving by concatenating range of references with range of prvalues seems to be reflected in join_view as well.

When the reference of the inner range is string&& and the reference of the pattern range is prvalue string, dereferencing its iterator will move the elements of the inner range to the returned string, which makes the second dereference get an empty string (demo):

vector v1{"hello"s};
vector v2{"world"s};
vector v{v1 | views::as_rvalue, v2 | views::as_rvalue};
auto pattern = views::iota(0, 1) | views::transform([](int) { return ", "s; });
ranges::forward_range auto joined = v | views::join_with(pattern);
fmt::print("{}\n", joined); // ["hello", ", ", "world"]
fmt::print("{}\n", joined); // ["", ", ", ""]

Not sure if we should ban such less common case.

[2023-10-30; Reflector poll]

Set priority to 3 after reflector poll. Send to SG9.

Proposed resolution: