public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Implement LWG 3904 change to lazy_split_view's iterator
@ 2023-04-11 14:58 Patrick Palka
  2023-04-11 15:06 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2023-04-11 14:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Patrick Palka

Tested on x86_64-pc-linux-gnu, does this look OK for trunk/12?

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/adjacent/1.cc (test04): Correct
	assertion.
	* testsuite/std/ranges/adaptors/lazy_split.cc (test12): New test.
---
 libstdc++-v3/include/std/ranges                  |  3 ++-
 .../testsuite/std/ranges/adaptors/adjacent/1.cc  |  2 +-
 .../testsuite/std/ranges/adaptors/lazy_split.cc  | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index b230ebefcf5..26a9f2a6872 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -3209,7 +3209,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/adjacent/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
index 443c1fbf450..19640abfe93 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
@@ -107,7 +107,7 @@ test04()
   // PR libstdc++/106798
   auto r = views::single(0) | views::lazy_split(0) | views::pairwise;
   decltype(ranges::cend(r)) s = r.end();
-  VERIFY( r.begin() == s );
+  VERIFY( r.begin() != s );
 
   return true;
 }
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc
index 9df6b3b66a6..4e5c0dc3ed5 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());
 }
-- 
2.40.0.315.g0607f793cb


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-11 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11 14:58 [PATCH] libstdc++: Implement LWG 3904 change to lazy_split_view's iterator Patrick Palka
2023-04-11 15:06 ` Jonathan Wakely

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