public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-7160] libstdc++: Implement LWG 3904 change to lazy_split_view's iterator
Date: Wed, 12 Apr 2023 17:05:06 +0000 (GMT)	[thread overview]
Message-ID: <20230412170506.A33763858D32@sourceware.org> (raw)

https://gcc.gnu.org/g:aa65771427d32299cffecea64cbb766411aa8faf

commit r13-7160-gaa65771427d32299cffecea64cbb766411aa8faf
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Apr 12 13:04:36 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/adjacent/1.cc (test04): Correct
            assertion.
            * testsuite/std/ranges/adaptors/lazy_split.cc (test12): New test.

Diff:
---
 libstdc++-v3/include/std/ranges                          |  3 ++-
 libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc |  2 +-
 libstdc++-v3/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 ba71976df8d..c21528138e5 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());
 }

                 reply	other threads:[~2023-04-12 17:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230412170506.A33763858D32@sourceware.org \
    --to=ppalka@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).