mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-26 04:25:51 +08:00
libstdc++: Fix noexcept-specifier for istream_iterator
Somehow I missed that the _M_value member can throw on construction. * include/bits/stream_iterator.h (istream_iterator(default_sentinel_t)): Make noexcept-specifier conditional. * testsuite/24_iterators/istream_iterator/cons/sentinel.cc: Check noexcept-specifier.
This commit is contained in:
parent
32b8f5df9f
commit
8566286eae
@ -1,5 +1,10 @@
|
||||
2020-02-24 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* include/bits/stream_iterator.h (istream_iterator(default_sentinel_t)):
|
||||
Make noexcept-specifier conditional.
|
||||
* testsuite/24_iterators/istream_iterator/cons/sentinel.cc: Check
|
||||
noexcept-specifier.
|
||||
|
||||
* include/bits/stream_iterator.h (istream_iterator(default_sentinel_t)):
|
||||
Add constructor.
|
||||
(operator==(istream_iterator, default_sentinel_t)): Add operator.
|
||||
|
@ -79,7 +79,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
#if __cplusplus > 201703L
|
||||
constexpr
|
||||
istream_iterator(default_sentinel_t) noexcept
|
||||
istream_iterator(default_sentinel_t)
|
||||
noexcept(is_nothrow_default_constructible_v<_Tp>)
|
||||
: istream_iterator() { }
|
||||
#endif
|
||||
|
||||
|
@ -19,9 +19,18 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <iterator>
|
||||
#include <istream>
|
||||
|
||||
// C++20 doesn't require this to be non-throwing.
|
||||
static_assert( std::is_nothrow_constructible_v<std::istream_iterator<int>,
|
||||
std::default_sentinel_t> );
|
||||
|
||||
constexpr std::istream_iterator<int> i = std::default_sentinel;
|
||||
|
||||
struct X { X() noexcept(false); };
|
||||
std::istream& operator<<(std::istream&, X&);
|
||||
|
||||
static_assert( std::is_constructible_v<std::istream_iterator<X>,
|
||||
std::default_sentinel_t> );
|
||||
static_assert( ! std::is_nothrow_constructible_v<std::istream_iterator<X>,
|
||||
std::default_sentinel_t> );
|
||||
|
Loading…
Reference in New Issue
Block a user