libstdc++: Make enumerate_view::iterator::operator- noexcept
Implement LWG 3912, approved in Varna, June 2023. libstdc++-v3/ChangeLog: * include/std/ranges (enumerate_view::_Iterator::operator-): Add noexcept, as per LWG 3912. * testsuite/std/ranges/adaptors/enumerate/1.cc: Check iterator difference is noexcept.
This commit is contained in:
parent
a08a5bc4b3
commit
c7449f1b15
2 changed files with 12 additions and 1 deletions
|
@ -9176,7 +9176,7 @@ namespace views::__adaptor
|
|||
{ return auto(__x) -= __y; }
|
||||
|
||||
friend constexpr difference_type
|
||||
operator-(const _Iterator& __x, const _Iterator& __y)
|
||||
operator-(const _Iterator& __x, const _Iterator& __y) noexcept
|
||||
{ return __x._M_pos - __y._M_pos; }
|
||||
|
||||
friend constexpr auto
|
||||
|
|
|
@ -91,6 +91,17 @@ test02()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_lwg3912()
|
||||
{
|
||||
int x[] = {1, 2, 3};
|
||||
test_input_range<int> rx (x);
|
||||
auto v = rx | views::enumerate;
|
||||
auto iter = std::ranges::begin(v);
|
||||
// LWG 3912. enumerate_view::iterator::operator- should be noexcept
|
||||
static_assert( noexcept(iter - iter) );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue