]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Implement LWG 3904 change to lazy_split_view's iterator
authorPatrick Palka <ppalka@redhat.com>
Wed, 12 Apr 2023 17:04:36 +0000 (13:04 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 12 Apr 2023 17:04:36 +0000 (13:04 -0400)
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
libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc

index ba71976df8db0ae38013949bd846a8906086141f..c21528138e5444c54e4fce4a1b39b3e51a67d58d 100644 (file)
@@ -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
index 443c1fbf450b42e1ceafdf4afb3725431e12172c..19640abfe93b0b91ed3f0573ca2b474026512912 100644 (file)
@@ -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;
 }
index 9df6b3b66a66e3915c0cbd4e712bac9e8393aff0..4e5c0dc3ed5b22f3779e021f863e617b9cecec80 100644 (file)
@@ -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());
 }
This page took 0.070367 seconds and 5 git commands to generate.