Files
2025-10-25 03:02:53 +03:00

70 lines
4.4 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[range.cache.latest.view]
# 25 Ranges library [[ranges]](./#ranges)
## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.cache.latest.view)
### 25.7.34 Cache latest view [[range.cache.latest]](range.cache.latest#view)
#### 25.7.34.2 Class template cache_latest_view [range.cache.latest.view]
namespace std::ranges {template<[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") V>requires [view](range.view#concept:view "25.4.5Views[range.view]")<V>class [cache_latest_view](#lib:cache_latest_view "25.7.34.2Class template cache_­latest_­view[range.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*// [[range.cache.latest.iterator]](range.cache.latest.iterator "25.7.34.3Class cache_­latest_­view::iterator"), class cache_latest_view::*iterator*class *iterator*; // *exposition only*// [[range.cache.latest.sentinel]](range.cache.latest.sentinel "25.7.34.4Class cache_­latest_­view::sentinel"), class cache_latest_view::*sentinel*class *sentinel*; // *exposition only*public: cache_latest_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12Concept default_­initializable[concept.default.init]")<V> = default; constexpr explicit cache_latest_view(V base); constexpr V base() const & requires [copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<V> { return *base_*; }constexpr V base() && { return std::move(*base_*); }constexpr auto begin(); constexpr auto end(); constexpr auto size() requires [sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]")<V>; constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]")<const V>; constexpr auto reserve_hint() requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]")<V>; constexpr auto reserve_hint() const requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]")<const V>; }; template<class R> cache_latest_view(R&&) -> cache_latest_view<views::all_t<R>>;}
[🔗](#lib:cache_latest_view,constructor)
`constexpr explicit cache_latest_view(V base);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17425)
*Effects*: Initializes *base_* with std::move(base)[.](#1.sentence-1)
[🔗](#lib:begin,cache_latest_view)
`constexpr auto begin();
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17436)
*Effects*: Equivalent to: return *iterator*(*this);
[🔗](#lib:end,cache_latest_view)
`constexpr auto end();
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17447)
*Effects*: Equivalent to: return *sentinel*(*this);
[🔗](#lib:size,cache_latest_view)
`constexpr auto size() requires [sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]")<V>;
constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4Sized ranges[range.sized]")<const V>;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17459)
*Effects*: Equivalent to: return ranges::size(*base_*);
[🔗](#lib:reserve_hint,cache_latest_view)
`constexpr auto reserve_hint() requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]")<V>;
constexpr auto reserve_hint() const requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3Approximately sized ranges[range.approximately.sized]")<const V>;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L17471)
*Effects*: Equivalent to: return ranges::reserve_hint(*base_*);