public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9498] libstdc++: Implement LWG 3904 change to lazy_split_view's iterator
@ 2023-04-29 14:04 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2023-04-29 14:04 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:05476c093a00c4ce31d7a19c72fc83b8796c05fe

commit r12-9498-g05476c093a00c4ce31d7a19c72fc83b8796c05fe
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Apr 12 13:08:21 2023 -0400

    libstdc++: Implement LWG 3904 change to lazy_split_view's iterator
    
    libstdc++-v3/ChangeLog:
    
            * include/std/ranges (lazy_split_view::_OuterIter::_OuterIter):
            Propagate _M_trailing_empty in the const-converting constructor
            as per LWG 3904.
            * testsuite/std/ranges/adaptors/lazy_split.cc (test12): New test.
    
    (cherry picked from commit aa65771427d32299cffecea64cbb766411aa8faf)

Diff:
---
 libstdc++-v3/include/std/ranges                          |  3 ++-
 libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 443fe65da92..bfcc046c496 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -3188,7 +3188,8 @@ namespace views::__adaptor
 	  _OuterIter(_OuterIter<!_Const> __i)
 	    requires _Const
 	      && convertible_to<iterator_t<_Vp>, iterator_t<_Base>>
-	    : _M_parent(__i._M_parent), _M_current(std::move(__i._M_current))
+	    : _M_parent(__i._M_parent), _M_current(std::move(__i._M_current)),
+	      _M_trailing_empty(__i._M_trailing_empty)
 	  { }
 
 	  constexpr value_type
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc
index 21c0837cdd3..5e1d99f636d 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc
@@ -22,6 +22,7 @@
 #include <ranges>
 #include <string>
 #include <string_view>
+#include <utility>
 #include <vector>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
@@ -218,6 +219,20 @@ test11()
   static_assert(ranges::distance(views::lazy_split("text"sv, ""sv)) == 4);
 }
 
+constexpr bool
+test12()
+{
+  // LWG 3904
+  auto r = views::single(0) | views::lazy_split(0);
+  auto i = r.begin();
+  ++i;
+  VERIFY( i != r.end() );
+  decltype(std::as_const(r).begin()) j = i;
+  VERIFY( j != r.end() );
+
+  return true;
+}
+
 int
 main()
 {
@@ -232,4 +247,5 @@ main()
   test09();
   test10();
   test11();
+  static_assert(test12());
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-29 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-29 14:04 [gcc r12-9498] libstdc++: Implement LWG 3904 change to lazy_split_view's iterator Patrick Palka

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).