summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-02-28 10:47:26 -0500
committerPatrick Palka <ppalka@redhat.com>2020-02-28 11:55:58 -0500
commit77e596cf3c1b7bc11ba946394ed8d62a49157b49 (patch)
tree6b6a0525d9558bd1e6a2c1f5b09f83b0e4e5dad0 /libstdc++-v3
parent08bf7bde9f2987b1c623d272cc71fc14a1622442 (diff)
libstdc++: Also disable caching of reverse_view::begin() for common_ranges
When the underlying range models common_range, then reverse_view::begin() is already O(1) without caching. So we should disable the cache in this case too. libstdc++-v3/ChangeLog: * include/std/ranges (reverse_view::_S_needs_cached_begin): Set to false whenever the underlying range models common_range.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog3
-rw-r--r--libstdc++-v3/include/std/ranges3
2 files changed, 5 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 89e1f5bf952..0feef87cce6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,8 @@
2020-02-28 Patrick Palka <ppalka@redhat.com>
+ * include/std/ranges (reverse_view::_S_needs_cached_begin): Set to false
+ whenever the underlying range models common_range.
+
* include/std/ranges (__detail::_CachedPosition): New struct.
(views::filter_view::_S_needs_cached_begin): New member variable.
(views::filter_view::_M_cached_begin): New member variable.
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 2f773130979..19d3da950e7 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -3177,7 +3177,8 @@ namespace views
private:
_Vp _M_base = _Vp();
- static constexpr bool _S_needs_cached_begin = !random_access_range<_Vp>;
+ static constexpr bool _S_needs_cached_begin
+ = !common_range<_Vp> && !random_access_range<_Vp>;
[[no_unique_address]]
__detail::__maybe_empty_t<_S_needs_cached_begin,
__detail::_CachedPosition<_Vp>> _M_cached_begin;