[range.cache.latest.iterator]

# 25 Ranges library [[ranges]](./#ranges)

## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.cache.latest.iterator)

### 25.7.34 Cache latest view [[range.cache.latest]](range.cache.latest#iterator)

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

[ð](#lib:cache_latest_view::iiterator)

namespace std::ranges {template<[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") V>requires [view](range.view#concept:view "25.4.5 Views [range.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](alg.req.ind.swap#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]")<iterator_t<V>>; };}

[ð](#lib:cache_latest_view::iterator,constructor)

`constexpr explicit iterator(cache_latest_view& parent);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17521)

*Effects*: Initializes *current_* withranges​::​begin(parent.*base_*) and *parent_* with addressof(parent)[.](#1.sentence-1)

[ð](#lib:base,cache_latest_view::iterator)

`constexpr iterator_t<V> base() &&;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17534)

*Returns*: std​::​move(*current_*)[.](#2.sentence-1)

[ð](#lib:base,cache_latest_view::iterator_)

`constexpr const iterator_t<V>& base() const & noexcept;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17545)

*Returns*: *current_*[.](#3.sentence-1)

[ð](#lib:operator++,cache_latest_view::iterator)

`constexpr iterator& operator++();
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17556)

*Effects*: Equivalent to:*parent_*->*cache_*.reset();++*current_*;return *this;

[ð](#lib:operator++,cache_latest_view::iterator_)

`constexpr void operator++(int);
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17572)

*Effects*: Equivalent to: ++*this[.](#5.sentence-1)

[ð](#lib:operator*,cache_latest_view::iterator)

`constexpr range_reference_t<V>& operator*() const;
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17583)

*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_*->c*ache_*) {*parent_*->*cache_*.*emplace-deref*(*current_*); }return **parent_*->*cache_*;}

[*Note [1](#note-1)*:

Evaluations of operator* on the same iterator object
can conflict ([[intro.races]](intro.races "6.10.2.2 Data races"))[.](#6.sentence-1)

â *end note*]

[ð](#lib:iter_move,cache_latest_view::iterator)

`friend constexpr range_rvalue_reference_t<V> iter_move(const iterator& i)
  noexcept(noexcept(ranges::iter_move(i.current_)));
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17612)

*Effects*: Equivalent to: return ranges​::​iter_move(i.*current_*);

[ð](#lib:iter_swap,cache_latest_view::iterator)

`friend constexpr void iter_swap(const iterator& x, const iterator& y)
  noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
  requires [indirectly_swappable](alg.req.ind.swap#concept:indirectly_swappable "24.3.7.4 Concept indirectly_­swappable [alg.req.ind.swap]")<iterator_t<V>>;
`

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17625)

*Effects*: Equivalent toranges​::​iter_swap(x.*current_*, y.*current_*)[.](#8.sentence-1)
