Commit 77e596cf by Patrick Palka

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.
parent 08bf7bde
2020-02-28 Patrick Palka <ppalka@redhat.com> 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. * include/std/ranges (__detail::_CachedPosition): New struct.
(views::filter_view::_S_needs_cached_begin): New member variable. (views::filter_view::_S_needs_cached_begin): New member variable.
(views::filter_view::_M_cached_begin): New member variable. (views::filter_view::_M_cached_begin): New member variable.
......
...@@ -3177,7 +3177,8 @@ namespace views ...@@ -3177,7 +3177,8 @@ namespace views
private: private:
_Vp _M_base = _Vp(); _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]] [[no_unique_address]]
__detail::__maybe_empty_t<_S_needs_cached_begin, __detail::__maybe_empty_t<_S_needs_cached_begin,
__detail::_CachedPosition<_Vp>> _M_cached_begin; __detail::_CachedPosition<_Vp>> _M_cached_begin;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment