]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Use conditional noexcept in std::reverse_iterator [PR 94418]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 28 Apr 2021 10:40:47 +0000 (11:40 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 1 Oct 2021 19:34:46 +0000 (20:34 +0100)
commitd335d73889d897d073b987b4323db05317fccad3
treee0536e7e62fc3341f428a75ae3d09781efdeb7fb
parent681707ec28d56494fa61a80c62500724d55f8586
libstdc++: Use conditional noexcept in std::reverse_iterator [PR 94418]

This adds a noexcept-specifier to each constructor and assignment
operator of std::reverse_iterator so that they are noexcept when the
corresponding operation on the underlying iterator is noexcept.

The std::reverse_iterator class template already requires that the
operations on the underlying type are valid, so we don't need to use the
std::is_nothrow_xxx traits to protect against errors when the expression
isn't even valid. We can just use a noexcept operator to test if the
expression can throw, without the overhead of redundantly checking if
the initialization/assignment would be valid.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/94418
* include/bits/stl_iterator.h (reverse_iterator): Use
conditional noexcept on constructors and assignment operators.
* testsuite/24_iterators/reverse_iterator/noexcept.cc: New test.
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/testsuite/24_iterators/reverse_iterator/noexcept.cc [new file with mode: 0644]
This page took 0.063611 seconds and 6 git commands to generate.