Skip to content

LWG-3880 Clarify operator+= complexity for {chunk,stride}_view::iterator #3434

@StephanTLavavej

Description

@StephanTLavavej

LWG-3880 Clarify operator+= complexity for {chunk,stride}_view::iterator

This appears to be related to #2995 cited in these operators:

STL/stl/inc/ranges

Lines 6232 to 6257 in 9ae1b3f

constexpr _Iterator& operator+=(const difference_type _Off) /* not strengthened, see _RANGES advance */
requires random_access_range<_Base>
{
if (_Off > 0) {
#if _ITERATOR_DEBUG_LEVEL != 0
_STL_VERIFY(_Count <= (numeric_limits<difference_type>::max)() / _Off,
"cannot advance chunk_view iterator past end (integer overflow)");
if constexpr (sized_sentinel_for<_Base_sentinel, _Base_iterator>) {
_STL_VERIFY(_End - _Current > _Count * (_Off - 1), //
"cannot advance chunk_view iterator past end");
}
#endif // _ITERATOR_DEBUG_LEVEL != 0
// Per to-be-filed LWG issue (See GH-2995)
if constexpr (sized_sentinel_for<_Base_sentinel, _Base_iterator>) {
_Missing = _RANGES advance(_Current, _Count * _Off, _End);
} else {
_Current += static_cast<difference_type>(_Count * (_Off - 1));
_Missing = _RANGES advance(_Current, _Count, _End);
}
} else if (_Off < 0) {
_Current += static_cast<difference_type>(_Count * _Off + _Missing);
_Missing = 0;
}
return *this;
}

STL/stl/inc/ranges

Lines 7182 to 7207 in 9ae1b3f

constexpr _Iterator& operator+=(const difference_type _Off)
requires random_access_range<_Base>
{
if (_Off > 0) {
#if _ITERATOR_DEBUG_LEVEL != 0
_STL_VERIFY(_Stride <= (numeric_limits<difference_type>::max)() / _Off,
"cannot advance stride_view iterator past end (integer overflow)");
if constexpr (sized_sentinel_for<_Base_sentinel, _Base_iterator>) {
_STL_VERIFY(_End - _Current > _Stride * (_Off - 1), //
"cannot advance stride_view iterator past end");
}
#endif // _ITERATOR_DEBUG_LEVEL != 0
// Per to-be-filed LWG issue (See GH-2995)
if constexpr (sized_sentinel_for<_Base_sentinel, _Base_iterator>) {
_Missing = _RANGES advance(_Current, _Stride * _Off, _End);
} else {
_Current += static_cast<difference_type>(_Stride * (_Off - 1));
_Missing = _RANGES advance(_Current, _Stride, _End);
}
} else if (_Off < 0) {
_Current += static_cast<difference_type>(_Stride * _Off + _Missing);
_Missing = 0;
}
return *this;
}

I haven't determined whether we can simply eliminate these comments, or if further changes are required to conform to the resolution of LWG-3880.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LWGLibrary Working Group issuefixedSomething works now, yay!rangesC++20/23 ranges

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions