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

3904. lazy_split_view::outer-iterator's const-converting constructor isn't setting trailing_empty_

Section: [range.lazy.split.outer] Status: WP Submitter: Patrick Palka Opened: 2023-03-13 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [range.lazy.split.outer].

View all issues with WP status.


It seems the const-converting constructor for lazy_split_view's iterator fails to propagate trailing_empty_ from the argument, which effectively results in the trailing empty range getting skipped over:

auto r = views::single(0) | views::lazy_split(0); // r is { {}, {} }
auto i = r.begin();
++i; // i.trailing_empty_ is correctly true
decltype(std::as_const(r).begin()) j = i; // j.trailing_empty_ is incorrectly false
auto k = r.end(); // k.trailing_empty_ is correctly false, and we wrongly have j == k

[2023-05-24; Reflector poll]

Set status to Tentatively Ready after five votes in favour during reflector poll.

[2023-06-17 Approved at June 2023 meeting in Varna. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4928.

  1. Modify [range.lazy.split.outer] as indicated:

    constexpr outer-iterator(outer-iterator<!Const> i)
      requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;

    -4- Effects: Initializes parent_ with i.parent_, and current_ with std::move(i.current_), and trailing_empty_ with i.trailing_empty_.