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.

4099. The simple case of views::as_rvalue and views::common are not strictly correct

Section: 25.7.7.1 [range.as.rvalue.overview], 25.7.20.1 [range.common.overview] Status: New Submitter: Hewill Kang Opened: 2024-05-10 Last modified: 2024-06-24

Priority: 4

View all other issues in [range.as.rvalue.overview].

View all issues with New status.

Discussion:

Currently, these two adaptors return views::all(E) when the type of subexpression E models common_range or its reference is the same as the rvalue reference.

However, the current wording does not require that a const-qualified object of a range type must have the same non-commonality or value category of the reference as the non-const one, this makes it theoretically possible for these two to still return non-common ranges or ranges whose reference are lvalue when acting on a const-qualified lvalue view object, because views::all(E) will remove the const-qualifier.

The proposed wording pedantically checks views::all_t<decltype((E))> instead of decltype((E)).

[2024-06-24; Reflector poll]

Set priority to 4 after reflector poll. "Not aware of any use case for making const affect those properties".

Proposed resolution:

This wording is relative to N4981.

  1. Modify 25.7.7.1 [range.as.rvalue.overview] as indicated:

    -2- The name views::as_rvalue denotes a range adaptor object (25.7.2 [range.adaptor.object]). Let E be an expression and let T be decltype((E)). The expression views::as_rvalue(E) is expression-equivalent to:

    1. (2.1) — views::all(E) if same_as<range_rvalue_reference_t<views::all_t<T>>, range_reference_t<views::all_t<T>>> is true.

    2. (2.2) — Otherwise, as_rvalue_view(E).

  2. Modify 25.7.20.1 [range.common.overview] as indicated:

    -3- The name views::common denotes a range adaptor object (25.7.2 [range.adaptor.object]). Given a subexpression E, the expression views::common(E) is expression-equivalent to:

    1. (3.1) — views::all(E), if decltype((E))views::all_t<T> models common_range and views::all(E) is a well-formed expression.

    2. (3.2) — Otherwise, common_view{E}.