]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Make std::istream_iterator copy ctor constexpr (LWG 3600)
authorJonathan Wakely <jwakely@redhat.com>
Wed, 22 Mar 2023 11:10:38 +0000 (11:10 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 13:50:53 +0000 (13:50 +0000)
As explained in LWG 3600, we never implemented a C++0x change that made
the copy constructor of std::istream_iterator defined as defaulted. That
would be an ABI break, so the resolution of LWG 3600 is to not require
it to be trivial, but just constexpr and conditionally noexcept. This
applies that resolution.

libstdc++-v3/ChangeLog:

* include/bits/stream_iterator.h (istream_iterator): Add
constexpr to copy constructor, as per LWG 3600.
* testsuite/24_iterators/istream_iterator/cons/constexpr.cc:
Check copy construction.

(cherry picked from commit ad0b9cf1a076fb9a802d9ba7fa2223aa3166dca2)

libstdc++-v3/include/bits/stream_iterator.h
libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/constexpr.cc

index 86c5845b8355ef640ad179b7b79527f0dc718384..019eaf840e7326b7f7eb3da5eeba4780162aff6e 100644 (file)
@@ -77,6 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       : _M_stream(std::__addressof(__s)), _M_ok(true)
       { _M_read(); }
 
+      _GLIBCXX_CONSTEXPR
       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),
index 6b973c611a7b3ee3e2e76738df80f9e34927e917..9570e7b928013ce8dde79278017e5e6b1bed50be 100644 (file)
@@ -24,5 +24,10 @@ int main()
 {
   __gnu_test::constexpr_default_constructible test;
   test.operator()<std::istream_iterator<char>>();
+
+  // LWG 3600. Making istream_iterator copy constructor trivial is an ABI break
+  __gnu_test::constexpr_single_value_constructible test2;
+  test2.operator()<std::istream_iterator<char>, std::istream_iterator<char>>();
+
   return 0;
 }
This page took 0.060817 seconds and 5 git commands to generate.