elements_view::iterator
Section: 25.7.23.3 [range.elements.iterator] Status: C++23 Submitter: Michael Schellenberger Costa Opened: 2020-10-28 Last modified: 2023-11-22
Priority: 0
View other active issues in [range.elements.iterator].
View all other issues in [range.elements.iterator].
View all issues with C++23 status.
Discussion:
During code review of elements_view
for MSVC-STL we found two issues that should be easily addressed:
elements_view::iterator
constraints both operator++(int)
member functions
constexpr void operator++(int) requires (!forward_range<Base>); constexpr iterator operator++(int) requires forward_range<Base>;
However, given that a constrained method would be preferred we only need to constrain one of those.
The proposal would be to remove the constraint from the void
returning overload and change
the declaration to
constexpr void operator++(int); constexpr iterator operator++(int) requires forward_range<Base>;
elements_view::iterator operator-
is constrained as follows:
friend constexpr difference_type operator-(const iterator& x, const iterator& y) requires random_access_range<Base>;
However, that requires its base to have operator-
defined. We should change the constraint to
sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>
:
friend constexpr difference_type operator-(const iterator& x, const iterator& y) requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
[2020-11-01; Daniel comments]
Bullet (2) of the discussion has already been resolved by LWG 3483, it has therefore been omitted from the proposed wording below.
[2020-11-15; Reflector prioritization]
Set priority to 0 and status to Tentatively Ready after five 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.
This wording intentionally only touches
operator++(int)
and notoperator-
, see the 2020-11-01 comment for the reason why.
Modify 25.7.23.3 [range.elements.iterator], class template elements_view::iterator
synopsis,
as indicated:
[…][…] constexpr iterator& operator++(); constexpr void operator++(int)requires (!forward_range<Base>); constexpr iterator operator++(int) requires forward_range<Base>; […]constexpr void operator++(int)requires (!forward_range<Base>);-6- Effects: Equivalent to:
++current_
.constexpr iterator operator++(int) requires forward_range<Base>;[…]