3490. ranges::drop_while_view::begin() is missing a precondition

Section: 25.7.13.2 [range.drop.while.view] Status: C++23 Submitter: Michael Schellenberger Costa Opened: 2020-10-13 Last modified: 2023-11-22

Priority: 0

View all other issues in [range.drop.while.view].

View all issues with C++23 status.

Discussion:

Similar to ranges::filter_view 25.7.8.2 [range.filter.view] p3, ranges::drop_while_view should have a precondition on its begin() method that the predicate is set.

I propose to add as 25.7.13.2 [range.drop.while.view] p3:

Preconditions: pred_.has_value().  

[2020-11-07; Reflector prioritization]

Set priority to 0 and status to Tentatively Ready after six votes in favour during reflector discussions.

[2021-02-26 Approved at February 2021 virtual plenary. Status changed: Tentatively Ready → WP.]

Proposed resolution:

This wording is relative to N4868.

  1. Modify 25.7.13.2 [range.drop.while.view] as indicated:

    Since we usually don't rely on implicit bool conversion in Preconditions: elements an explicit "is true" has been added. Editorial fixes of the referenced paragraph 25.7.13.2 [range.drop.while.view] p3 and similar places have been requested separately.

    constexpr auto begin();
    

    -?- Preconditions: pred_.has_value() is true.

    -3- Returns: ranges::find_if_not(base_, cref(*pred_)).

    -4- […]