From Jason Turner

[range.lazy.split.outer]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxqda6_5_/{from.md → to.md} +150 -0
tmp/tmpxqda6_5_/{from.md → to.md} RENAMED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `lazy_split_view::outer-iterator` <a id="range.lazy.split.outer">[[range.lazy.split.outer]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<input_range V, forward_range Pattern>
6
+ requires view<V> && view<Pattern> &&
7
+ indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> &&
8
+ (forward_range<V> || tiny-range<Pattern>)
9
+ template<bool Const>
10
+ struct lazy_split_view<V, Pattern>::outer-iterator {
11
+ private:
12
+ using Parent = maybe-const<Const, lazy_split_view>; // exposition only
13
+ using Base = maybe-const<Const, V>; // exposition only
14
+ Parent* parent_ = nullptr; // exposition only
15
+
16
+ iterator_t<Base> current_ = iterator_t<Base>(); // exposition only, present only
17
+ // if V models forward_range
18
+
19
+ bool trailing_empty_ = false; // exposition only
20
+
21
+ public:
22
+ using iterator_concept =
23
+ conditional_t<forward_range<Base>, forward_iterator_tag, input_iterator_tag>;
24
+
25
+ using iterator_category = input_iterator_tag; // present only if Base
26
+ // models forward_range
27
+
28
+ // [range.lazy.split.outer.value], class lazy_split_view::outer-iterator::value_type
29
+ struct value_type;
30
+ using difference_type = range_difference_t<Base>;
31
+
32
+ outer-iterator() = default;
33
+ constexpr explicit outer-iterator(Parent& parent)
34
+ requires (!forward_range<Base>);
35
+ constexpr outer-iterator(Parent& parent, iterator_t<Base> current)
36
+ requires forward_range<Base>;
37
+ constexpr outer-iterator(outer-iterator<!Const> i)
38
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
39
+
40
+ constexpr value_type operator*() const;
41
+
42
+ constexpr outer-iterator& operator++();
43
+ constexpr decltype(auto) operator++(int) {
44
+ if constexpr (forward_range<Base>) {
45
+ auto tmp = *this;
46
+ ++*this;
47
+ return tmp;
48
+ } else
49
+ ++*this;
50
+ }
51
+
52
+ friend constexpr bool operator==(const outer-iterator& x, const outer-iterator& y)
53
+ requires forward_range<Base>;
54
+
55
+ friend constexpr bool operator==(const outer-iterator& x, default_sentinel_t);
56
+ };
57
+ }
58
+ ```
59
+
60
+ Many of the specifications in [[range.lazy.split]] refer to the notional
61
+ member *current* of *`outer-iterator`*. *current* is equivalent to
62
+ *`current_`* if `V` models `forward_range`, and `*parent_->current_`
63
+ otherwise.
64
+
65
+ ``` cpp
66
+ constexpr explicit outer-iterator(Parent& parent)
67
+ requires (!forward_range<Base>);
68
+ ```
69
+
70
+ *Effects:* Initializes *parent\_* with `addressof(parent)`.
71
+
72
+ ``` cpp
73
+ constexpr outer-iterator(Parent& parent, iterator_t<Base> current)
74
+ requires forward_range<Base>;
75
+ ```
76
+
77
+ *Effects:* Initializes *parent\_* with `addressof(parent)` and
78
+ *current\_* with `std::move(current)`.
79
+
80
+ ``` cpp
81
+ constexpr outer-iterator(outer-iterator<!Const> i)
82
+ requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
83
+ ```
84
+
85
+ *Effects:* Initializes *parent\_* with `i.`*`parent_`* and *current\_*
86
+ with `std::move(i.`*`current_`*`)`.
87
+
88
+ ``` cpp
89
+ constexpr value_type operator*() const;
90
+ ```
91
+
92
+ *Effects:* Equivalent to: `return value_type{*this};`
93
+
94
+ ``` cpp
95
+ constexpr outer-iterator& operator++();
96
+ ```
97
+
98
+ *Effects:* Equivalent to:
99
+
100
+ ``` cpp
101
+ const auto end = ranges::end(parent_->base_);
102
+ if (current == end) {
103
+ trailing_empty_ = false;
104
+ return *this;
105
+ }
106
+ const auto [pbegin, pend] = subrange{parent_->pattern_};
107
+ if (pbegin == pend) ++current;
108
+ else if constexpr (tiny-range<Pattern>) {
109
+ current = ranges::find(std::move(current), end, *pbegin);
110
+ if (current != end) {
111
+ ++current;
112
+ if (current == end)
113
+ trailing_empty_ = true;
114
+ }
115
+ }
116
+ else {
117
+ do {
118
+ auto [b, p] = ranges::mismatch(current, end, pbegin, pend);
119
+ if (p == pend) {
120
+ current = b;
121
+ if (current == end)
122
+ trailing_empty_ = true;
123
+ break; // The pattern matched; skip it
124
+ }
125
+ } while (++current != end);
126
+ }
127
+ return *this;
128
+ ```
129
+
130
+ ``` cpp
131
+ friend constexpr bool operator==(const outer-iterator& x, const outer-iterator& y)
132
+ requires forward_range<Base>;
133
+ ```
134
+
135
+ *Effects:* Equivalent to:
136
+
137
+ ``` cpp
138
+ return x.current_ == y.current_ && x.trailing_empty_ == y.trailing_empty_;
139
+ ```
140
+
141
+ ``` cpp
142
+ friend constexpr bool operator==(const outer-iterator& x, default_sentinel_t);
143
+ ```
144
+
145
+ *Effects:* Equivalent to:
146
+
147
+ ``` cpp
148
+ return x.current == ranges::end(x.parent_->base_) && !x.trailing_empty_;
149
+ ```
150
+