From Jason Turner

[range.cache.latest.iterator]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvkg7m_xz/{from.md → to.md} +115 -0
tmp/tmpvkg7m_xz/{from.md → to.md} RENAMED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class `cache_latest_view::iterator` <a id="range.cache.latest.iterator">[[range.cache.latest.iterator]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<input_range V>
6
+ requires view<V>
7
+ class cache_latest_view<V>::iterator {
8
+ cache_latest_view* parent_; // exposition only
9
+ iterator_t<V> current_; // exposition only
10
+
11
+ constexpr explicit iterator(cache_latest_view& parent); // exposition only
12
+
13
+ public:
14
+ using difference_type = range_difference_t<V>;
15
+ using value_type = range_value_t<V>;
16
+ using iterator_concept = input_iterator_tag;
17
+
18
+ iterator(iterator&&) = default;
19
+ iterator& operator=(iterator&&) = default;
20
+
21
+ constexpr iterator_t<V> base() &&;
22
+ constexpr const iterator_t<V>& base() const & noexcept;
23
+
24
+ constexpr range_reference_t<V>& operator*() const;
25
+
26
+ constexpr iterator& operator++();
27
+ constexpr void operator++(int);
28
+
29
+ friend constexpr range_rvalue_reference_t<V> iter_move(const iterator& i)
30
+ noexcept(noexcept(ranges::iter_move(i.current_)));
31
+
32
+ friend constexpr void iter_swap(const iterator& x, const iterator& y)
33
+ noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
34
+ requires indirectly_swappable<iterator_t<V>>;
35
+ };
36
+ }
37
+ ```
38
+
39
+ ``` cpp
40
+ constexpr explicit iterator(cache_latest_view& parent);
41
+ ```
42
+
43
+ *Effects:* Initializes *current\_* with
44
+ `ranges::begin(parent.`*`base_`*`)` and *parent\_* with
45
+ `addressof(parent)`.
46
+
47
+ ``` cpp
48
+ constexpr iterator_t<V> base() &&;
49
+ ```
50
+
51
+ *Returns:* `std::move(`*`current_`*`)`.
52
+
53
+ ``` cpp
54
+ constexpr const iterator_t<V>& base() const & noexcept;
55
+ ```
56
+
57
+ *Returns:* *current\_*.
58
+
59
+ ``` cpp
60
+ constexpr iterator& operator++();
61
+ ```
62
+
63
+ *Effects:* Equivalent to:
64
+
65
+ ``` cpp
66
+ parent_->cache_.reset();
67
+ ++current_;
68
+ return *this;
69
+ ```
70
+
71
+ ``` cpp
72
+ constexpr void operator++(int);
73
+ ```
74
+
75
+ *Effects:* Equivalent to: `++*this`.
76
+
77
+ ``` cpp
78
+ constexpr range_reference_t<V>& operator*() const;
79
+ ```
80
+
81
+ *Effects:* Equivalent to:
82
+
83
+ ``` cpp
84
+ if constexpr (is_reference_v<range_reference_t<V>>) {
85
+ if (!parent_->cache_) {
86
+ parent_->cache_ = addressof(as-lvalue(*current_));
87
+ }
88
+ return **parent_->cache_;
89
+ } else {
90
+ if (!parent_->cache_) {
91
+ parent_->cache_.emplace-deref(current_);
92
+ }
93
+ return *parent_->cache_;
94
+ }
95
+ ```
96
+
97
+ [*Note 1*: Evaluations of `operator*` on the same iterator object can
98
+ conflict [[intro.races]]. — *end note*]
99
+
100
+ ``` cpp
101
+ friend constexpr range_rvalue_reference_t<V> iter_move(const iterator& i)
102
+ noexcept(noexcept(ranges::iter_move(i.current_)));
103
+ ```
104
+
105
+ *Effects:* Equivalent to: `return ranges::iter_move(i.`*`current_`*`);`
106
+
107
+ ``` cpp
108
+ friend constexpr void iter_swap(const iterator& x, const iterator& y)
109
+ noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
110
+ requires indirectly_swappable<iterator_t<V>>;
111
+ ```
112
+
113
+ *Effects:* Equivalent to
114
+ `ranges::iter_swap(x.`*`current_`*`, y.`*`current_`*`)`.
115
+