public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4048] libstdc++: Add noexcept to istream_iterator and ostream_iterator Date: Fri, 1 Oct 2021 14:04:37 +0000 (GMT) [thread overview] Message-ID: <20211001140437.AE727385842F@sourceware.org> (raw) https://gcc.gnu.org/g:901fa4cc27ce693b361220818732556bfa586eea commit r12-4048-g901fa4cc27ce693b361220818732556bfa586eea Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Sep 30 14:39:36 2021 +0100 libstdc++: Add noexcept to istream_iterator and ostream_iterator libstdc++-v3/ChangeLog: * include/bits/stream_iterator.h (istream_iterator): Add noexcept to constructors and non-throwing member functions and friend functions. (ostream_iterator): Likewise. Diff: --- libstdc++-v3/include/bits/stream_iterator.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/include/bits/stream_iterator.h b/libstdc++-v3/include/bits/stream_iterator.h index d74c158f342..5a132319111 100644 --- a/libstdc++-v3/include/bits/stream_iterator.h +++ b/libstdc++-v3/include/bits/stream_iterator.h @@ -65,6 +65,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: /// Construct end of input stream iterator. _GLIBCXX_CONSTEXPR istream_iterator() + _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Tp>::value) : _M_stream(0), _M_value(), _M_ok(false) {} /// Construct start of input stream iterator. @@ -73,6 +74,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { _M_read(); } istream_iterator(const istream_iterator& __obj) + _GLIBCXX_NOEXCEPT_IF(is_nothrow_copy_constructible<_Tp>::value) : _M_stream(__obj._M_stream), _M_value(__obj._M_value), _M_ok(__obj._M_ok) { } @@ -91,7 +93,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_NODISCARD const _Tp& - operator*() const + operator*() const _GLIBCXX_NOEXCEPT { __glibcxx_requires_cond(_M_ok, _M_message(__gnu_debug::__msg_deref_istream) @@ -101,7 +103,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_NODISCARD const _Tp* - operator->() const { return std::__addressof((operator*())); } + operator->() const _GLIBCXX_NOEXCEPT + { return std::__addressof((operator*())); } istream_iterator& operator++() @@ -126,7 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION private: bool - _M_equal(const istream_iterator& __x) const + _M_equal(const istream_iterator& __x) const _GLIBCXX_NOEXCEPT { // Ideally this would just return _M_stream == __x._M_stream, // but code compiled with old versions never sets _M_stream to null. @@ -148,6 +151,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_NODISCARD friend bool operator==(const istream_iterator& __x, const istream_iterator& __y) + _GLIBCXX_NOEXCEPT { return __x._M_equal(__y); } #if __cpp_impl_three_way_comparison < 201907L @@ -156,13 +160,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_NODISCARD friend bool operator!=(const istream_iterator& __x, const istream_iterator& __y) + _GLIBCXX_NOEXCEPT { return !__x._M_equal(__y); } #endif #if __cplusplus > 201703L && __cpp_lib_concepts [[nodiscard]] friend bool - operator==(const istream_iterator& __i, default_sentinel_t) + operator==(const istream_iterator& __i, default_sentinel_t) noexcept { return !__i._M_stream; } #endif }; @@ -200,7 +205,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: /// Construct from an ostream. - ostream_iterator(ostream_type& __s) + ostream_iterator(ostream_type& __s) _GLIBCXX_NOEXCEPT : _M_stream(std::__addressof(__s)), _M_string(0) {} /** @@ -213,11 +218,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @param __s Underlying ostream to write to. * @param __c CharT delimiter string to insert. */ - ostream_iterator(ostream_type& __s, const _CharT* __c) + ostream_iterator(ostream_type& __s, const _CharT* __c) _GLIBCXX_NOEXCEPT : _M_stream(std::__addressof(__s)), _M_string(__c) { } /// Copy constructor. - ostream_iterator(const ostream_iterator& __obj) + ostream_iterator(const ostream_iterator& __obj) _GLIBCXX_NOEXCEPT : _M_stream(__obj._M_stream), _M_string(__obj._M_string) { } #if __cplusplus >= 201103L @@ -240,15 +245,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_NODISCARD ostream_iterator& - operator*() + operator*() _GLIBCXX_NOEXCEPT { return *this; } ostream_iterator& - operator++() + operator++() _GLIBCXX_NOEXCEPT { return *this; } ostream_iterator& - operator++(int) + operator++(int) _GLIBCXX_NOEXCEPT { return *this; } };
reply other threads:[~2021-10-01 14:04 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211001140437.AE727385842F@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).