From: Patrick Palka <ppalka@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: libstdc++@gcc.gnu.org, Patrick Palka <ppalka@redhat.com>
Subject: [PATCH] libstdc++: Implement LWG 3904 change to lazy_split_view's iterator
Date: Tue, 11 Apr 2023 10:58:31 -0400 [thread overview]
Message-ID: <20230411145831.2862333-1-ppalka@redhat.com> (raw)
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
next reply other threads:[~2023-04-11 14:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 14:58 Patrick Palka [this message]
2023-04-11 15:06 ` Jonathan Wakely
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=20230411145831.2862333-1-ppalka@redhat.com \
--to=ppalka@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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).