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.
Section: 26.7.21.1 [range.as.const.overview] Status: WP Submitter: Hewill Kang Opened: 2023-01-06 Last modified: 2023-02-13
Priority: Not Prioritized
View all other issues in [range.as.const.overview].
View all issues with WP status.
Discussion:
Currently, applying views::as_const to an empty_view<int> will result in an as_const_view<empty_view<int>>, and its iterator type will be basic_const_iterator<int*>.
This amount of instantiation is not desirable for such a simple view, in which case simply returning empty_view<const int> should be enough.
[2023-02-01; Reflector poll]
Set status to Tentatively Ready after eight votes in favour during reflector poll.
[2023-02-13 Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4917.
Modify 26.7.21.1 [range.as.const.overview] as indicated:
-2- The name views::as_const denotes a range adaptor object (26.7.2 [range.adaptor.object]). Let E be an expression, let T be decltype((E)), and let U be remove_cvref_t<T>. The expression views::as_const(E) is expression-equivalent to:
(2.1) — If views::all_t<T> models constant_range, then views::all(E).
(2.?) — Otherwise, if U denotes empty_view<X> for some type X, then auto(views::empty<const X>).
(2.2) — Otherwise, if U denotes span<X, Extent> for some type X and some extent Extent, then span<const X, Extent>(E).
(2.3) — Otherwise, if E is an lvalue, const U models constant_range, and U does not model view, then ref_view(static_cast<const U&>(E)).
(2.4) — Otherwise, as_const_view(E).