public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-855] libstdc++: Fix condition for memoizing reverse_view::begin() [PR100621]
@ 2021-05-18  4:35 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2021-05-18  4:35 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:03cf8d54e5c27cfe6b184cc96757cab30d8fa1df

commit r12-855-g03cf8d54e5c27cfe6b184cc96757cab30d8fa1df
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue May 18 00:26:25 2021 -0400

    libstdc++: Fix condition for memoizing reverse_view::begin() [PR100621]
    
    A range being a random access range isn't a sufficient condition for
    ranges::next(iter, sent) to have constant time complexity -- it must
    also have a sized sentinel.  This adjusts the memoization condition for
    reverse_view accordingly.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100621
            * include/std/ranges (reverse_view::_S_needs_cached_begin):
            Set to true if the underlying non-common random-access range
            doesn't have a sized sentinel.

Diff:
---
 libstdc++-v3/include/std/ranges | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 36bccd6b33b..70794251ec7 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -3228,7 +3228,9 @@ namespace views::__adaptor
     {
     private:
       static constexpr bool _S_needs_cached_begin
-	= !common_range<_Vp> && !random_access_range<_Vp>;
+	= !common_range<_Vp> && !(random_access_range<_Vp>
+				  && sized_sentinel_for<sentinel_t<_Vp>,
+							iterator_t<_Vp>>);
 
       [[no_unique_address]]
 	__detail::__maybe_present_t<_S_needs_cached_begin,


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-18  4:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  4:35 [gcc r12-855] libstdc++: Fix condition for memoizing reverse_view::begin() [PR100621] Patrick Palka

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