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-3386] libstdc++: Fix typo in stride_view's operator- [PR107313] Date: Wed, 19 Oct 2022 17:04:16 +0000 (GMT) [thread overview] Message-ID: <20221019170417.21F2C3858C83@sourceware.org> (raw) https://gcc.gnu.org/g:a10d6b5eb999a74fd4b12c00e8fb379cd3460e93 commit r13-3386-ga10d6b5eb999a74fd4b12c00e8fb379cd3460e93 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Oct 19 13:03:25 2022 -0400 libstdc++: Fix typo in stride_view's operator- [PR107313] PR libstdc++/107313 libstdc++-v3/ChangeLog: * include/std/ranges (stride_view::_Iterator::operator-): Fix typo. * testsuite/std/ranges/adaptors/stride/1.cc (test03): New test. Diff: --- libstdc++-v3/include/std/ranges | 2 +- .../testsuite/std/ranges/adaptors/stride/1.cc | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index d113cf19dc7..b29264931cc 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -7874,7 +7874,7 @@ namespace views::__adaptor friend constexpr difference_type operator-(default_sentinel_t __y, const _Iterator& __x) requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>> - { return __detail::__div_ceil(__x._M_end, __x._M_current, __x._M_stride); } + { return __detail::__div_ceil(__x._M_end - __x._M_current, __x._M_stride); } friend constexpr difference_type operator-(const _Iterator& __x, default_sentinel_t __y) diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc index 745d1a61c1b..37ae896014a 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc @@ -64,10 +64,30 @@ test02() VERIFY( ranges::equal(v, (int[]){1, 4, 7}) ); } +void +test03() +{ + // PR libstdc++/107313 + int x[] = {1, 2, 3, 4, 5}; + __gnu_test::test_input_range<int> rx(x); + auto r = views::counted(rx.begin(), 4) | views::stride(2); + auto i = r.begin(); + std::default_sentinel_t s = r.end(); + VERIFY( s != i ); + VERIFY( s - i == 2 && i - s == -2 ); + ++i; + VERIFY( s != i ); + VERIFY( s - i == 1 && i - s == -1 ); + ++i; + VERIFY( s == i ); + VERIFY( s - i == 0 && i - s == 0 ); +} + int main() { static_assert(test01()); test02<__gnu_test::test_input_range<int>>(); test02<__gnu_test::test_forward_range<int>>(); + test03(); }
reply other threads:[~2022-10-19 17:04 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=20221019170417.21F2C3858C83@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: linkBe 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).