On 24/02/20 13:40 +0000, Jonathan Wakely wrote:
Missing pieces of P0896R4 "The One Ranges Proposal" for C++20.

        * include/bits/stream_iterator.h (istream_iterator(default_sentinel_t)):
        Add constructor.
        (operator==(istream_iterator, default_sentinel_t)): Add operator.
        (ostream_iterator::difference_type): Define to ptrdiff_t for C++20.
        * include/bits/streambuf_iterator.h
        (istreambuf_iterator(default_sentinel_t)): Add constructor.
        (operator==(istreambuf_iterator, default_sentinel_t)): Add operator.
        * testsuite/24_iterators/istream_iterator/cons/sentinel.cc:
        New test.
        * testsuite/24_iterators/istream_iterator/sentinel.cc: New test.
        * testsuite/24_iterators/istreambuf_iterator/cons/sentinel.cc:
        New test.
        * testsuite/24_iterators/istreambuf_iterator/sentinel.cc: New test.

This fixes a dumb mistake in that commit.

Tested powerpc64le-linux, committed to master.


commit 8566286eaeb9a977339df88212826150767f1203
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Feb 24 14:22:21 2020 +0000

    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.

diff --git a/libstdc++-v3/include/bits/stream_iterator.h b/libstdc++-v3/include/bits/stream_iterator.h
index 1ddf647f729..9d8ead092b8 100644
--- a/libstdc++-v3/include/bits/stream_iterator.h
+++ b/libstdc++-v3/include/bits/stream_iterator.h
@@ -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
 
diff --git a/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/sentinel.cc b/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/sentinel.cc
index 77a19498817..b890f04f8e9 100644
--- a/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/sentinel.cc
+++ b/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/sentinel.cc
@@ -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> );

Reply via email to