Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
StephanTLavavej opened this issue Feb 12, 2023 · 0 comments · Fixed by #3554
Closed

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

StephanTLavavej opened this issue Feb 12, 2023 · 0 comments · Fixed by #3554
Labels
fixed Something works now, yay! LWG Library Working Group issue ranges C++20/23 ranges

Comments

@StephanTLavavej
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Something works now, yay! LWG Library Working Group issue ranges C++20/23 ranges
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant