From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id A77073857C60 for ; Fri, 1 Oct 2021 14:05:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A77073857C60 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-XlMX3zS8Op2wbl8ZtG8-EQ-1; Fri, 01 Oct 2021 10:05:37 -0400 X-MC-Unique: XlMX3zS8Op2wbl8ZtG8-EQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C68C1006AA4; Fri, 1 Oct 2021 14:05:36 +0000 (UTC) Received: from localhost (unknown [10.33.36.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6E1A21ECB; Fri, 1 Oct 2021 14:05:35 +0000 (UTC) Date: Fri, 1 Oct 2021 15:05:34 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add noexcept to istream_iterator and ostream_iterator Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="YfOVPMAULn4NcIYM" Content-Disposition: inline X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2021 14:05:40 -0000 --YfOVPMAULn4NcIYM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. Tested x86_64-linux. Committed to trunk. --YfOVPMAULn4NcIYM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 901fa4cc27ce693b361220818732556bfa586eea Author: Jonathan Wakely Date: Thu Sep 30 14:39:36 2021 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 --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; } }; --YfOVPMAULn4NcIYM--