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.
repeat_view::iteratorSection: 25.6.5.3 [range.repeat.iterator] Status: New Submitter: Tomasz Kamiński Opened: 2026-09-21 Last modified: 2026-09-21
Priority: Not Prioritized
View other active issues in [range.repeat.iterator].
View all other issues in [range.repeat.iterator].
View all issues with New status.
Discussion:
As currently specified, the preconditions requiring current_ to be
non-negative (25.6.5.3 [range.repeat.iterator] p2, p6, p8, p10) are applied
only if "If Bound is not unreachable_sentinel_t". In consequence,
decrementing iterator before begin is UB only if views::repeat specifies bound:
auto rv1 = views::repeat(1, 10); auto it1 = std::prev(rv1.begin()); // UB auto rv2 = views::repeat(1); auto it2 = std::prev(rv2.begin()); // OKIn contrast to the precondition on
bound in repeat_view constructor,
the current_ is of ptrdiff_t type in such case, and the check
can always be performed.
On the LWG reflector Michał Dominiak (the author of the paper) confirmed, that this is unintentional copy-paste error in the wording, and the precondition should always be applied.
Proposed resolution:
This wording is relative to N5054.
The proposed resolution completely removes the precondition on private constructor
iterator(const T* value, index-type b = index-type()),
as it is private and can only be invoked by the library internally.
Modify 25.6.5.3 [range.repeat.iterator] as indicated:
[…]constexpr explicit iterator(const T* value, index-type b = index-type());
-1- Preconditions: If.Boundis notunreachable_sentinel_t,b≥ 0-2- Effects: […]
constexpr explicit iterator& operator--();-6- Preconditions:
IfBoundis notunreachable_sentinel_t,current_≥ 0.-7- Effects: […]
constexpr explicit iterator& operator+=(difference_type n);-8- Preconditions:
IfBoundis notunreachable_sentinel_t,current_+n≥ 0.-9- Effects: […]
constexpr explicit iterator& operator-=(difference_type n);-10- Preconditions:
IfBoundis notunreachable_sentinel_t,current_-n≥ 0.-11- Effects: […]