25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.34 Cache latest view [range.cache.latest]

25.7.34.2 Class template cache_latest_view [range.cache.latest.view]

namespace std::ranges { template<input_range V> requires view<V> class cache_latest_view : public view_interface<cache_latest_view<V>> { V base_ = V(); // exposition only using cache-t = conditional_t<is_reference_v<range_reference_t<V>>, // exposition only add_pointer_t<range_reference_t<V>>, range_reference_t<V>>; non-propagating-cache<cache-t> cache_; // exposition only class iterator; // exposition only class sentinel; // exposition only public: cache_latest_view() requires default_initializable<V> = default; constexpr explicit cache_latest_view(V base); constexpr V base() const & requires copy_constructible<V> { return base_; } constexpr V base() && { return std::move(base_); } constexpr auto begin(); constexpr auto end(); constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>; }; template<class R> cache_latest_view(R&&) -> cache_latest_view<views::all_t<R>>; }
constexpr explicit cache_latest_view(V base);
Effects: Initializes base_ with std​::​move(base).
constexpr auto begin();
Effects: Equivalent to: return iterator(*this);
constexpr auto end();
Effects: Equivalent to: return sentinel(*this);
constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>;
Effects: Equivalent to: return ranges​::​size(base_);