25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.34 Cache latest view [range.cache.latest]

25.7.34.3 Class cache_latest_view​::​iterator [range.cache.latest.iterator]

namespace std::ranges { template<input_range V> requires view<V> class cache_latest_view<V>::iterator { cache_latest_view* parent_; // exposition only iterator_t<V> current_; // exposition only constexpr explicit iterator(cache_latest_view& parent); // exposition only public: using difference_type = range_difference_t<V>; using value_type = range_value_t<V>; using iterator_concept = input_iterator_tag; iterator(iterator&&) = default; iterator& operator=(iterator&&) = default; constexpr iterator_t<V> base() &&; constexpr const iterator_t<V>& base() const & noexcept; constexpr range_reference_t<V>& operator*() const; constexpr iterator& operator++(); constexpr void operator++(int); friend constexpr range_rvalue_reference_t<V> iter_move(const iterator& i) noexcept(noexcept(ranges::iter_move(i.current_))); friend constexpr void iter_swap(const iterator& x, const iterator& y) noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) requires indirectly_swappable<iterator_t<V>>; }; }
constexpr explicit iterator(cache_latest_view& parent);
Effects: Initializes current_ with ranges​::​begin(parent.base_) and parent_ with addressof(parent).
constexpr iterator_t<V> base() &&;
Returns: std​::​move(current_).
constexpr const iterator_t<V>& base() const & noexcept;
Returns: current_.
constexpr iterator& operator++();
Effects: Equivalent to: parent_->cache_.reset(); ++current_; return *this;
constexpr void operator++(int);
Effects: Equivalent to: ++*this.
constexpr range_reference_t<V>& operator*() const;
Effects: Equivalent to: if constexpr (is_reference_v<range_reference_t<V>>) { if (!parent_->cache_) { parent_->cache_ = addressof(as-lvalue(*current_)); } return **parent_->cache_; } else { if (!parent_->cache_) { parent_->cache_.emplace-deref(current_); } return *parent_->cache_; }
[Note 1: 
Evaluations of operator* on the same iterator object can conflict ([intro.races]).
— end note]
friend constexpr range_rvalue_reference_t<V> iter_move(const iterator& i) noexcept(noexcept(ranges::iter_move(i.current_)));
Effects: Equivalent to: return ranges​::​iter_move(i.current_);
friend constexpr void iter_swap(const iterator& x, const iterator& y) noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) requires indirectly_swappable<iterator_t<V>>;
Effects: Equivalent to ranges​::​iter_swap(x.current_, y.current_).