From Jason Turner

[re.iter]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpv5yokx0j/{from.md → to.md} +64 -61
tmp/tmpv5yokx0j/{from.md → to.md} RENAMED
@@ -24,39 +24,37 @@ is not equal to a non-end-of-sequence iterator. Two non-end-of-sequence
24
  iterators are equal when they are constructed from the same arguments.
25
 
26
  ``` cpp
27
  namespace std {
28
  template <class BidirectionalIterator,
29
- class charT = typename iterator_traits<
30
- BidirectionalIterator>::value_type,
31
  class traits = regex_traits<charT>>
32
  class regex_iterator {
33
  public:
34
- typedef basic_regex<charT, traits> regex_type;
35
- typedef match_results<BidirectionalIterator> value_type;
36
- typedef std::ptrdiff_t difference_type;
37
- typedef const value_type* pointer;
38
- typedef const value_type& reference;
39
- typedef std::forward_iterator_tag iterator_category;
40
 
41
  regex_iterator();
42
  regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
43
  const regex_type& re,
44
- regex_constants::match_flag_type m =
45
- regex_constants::match_default);
46
- regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
47
- const regex_type&& re,
48
- regex_constants::match_flag_type m =
49
- regex_constants::match_default) = delete;
50
  regex_iterator(const regex_iterator&);
51
  regex_iterator& operator=(const regex_iterator&);
52
  bool operator==(const regex_iterator&) const;
53
  bool operator!=(const regex_iterator&) const;
54
  const value_type& operator*() const;
55
  const value_type* operator->() const;
56
  regex_iterator& operator++();
57
  regex_iterator operator++(int);
 
58
  private:
59
  BidirectionalIterator begin; // exposition only
60
  BidirectionalIterator end; // exposition only
61
  const regex_type* pregex; // exposition only
62
  regex_constants::match_flag_type flags; // exposition only
@@ -65,13 +63,15 @@ namespace std {
65
  }
66
  ```
67
 
68
  An object of type `regex_iterator` that is not an end-of-sequence
69
  iterator holds a *zero-length match* if `match[0].matched == true` and
70
- `match[0].first == match[0].second`. For example, this can occur when
71
- the part of the regular expression that matched consists only of an
72
- assertion (such as `'^'`, `'$'`, `'\b'`, `'\B'`).
 
 
73
 
74
  #### `regex_iterator` constructors <a id="re.regiter.cnstr">[[re.regiter.cnstr]]</a>
75
 
76
  ``` cpp
77
  regex_iterator();
@@ -139,43 +139,50 @@ regex_iterator& operator++();
139
 
140
  If the iterator holds a zero-length match and `start == end` the
141
  operator sets `*this` to the end-of-sequence iterator and returns
142
  `*this`.
143
 
144
- Otherwise, if the iterator holds a zero-length match the operator calls
145
- `regex_search(start, end, match, *pregex, flags `|` regex_constants::match_not_null `|` regex_constants::match_`
146
- `continuous)`. If the call returns `true` the operator returns `*this`.
147
- Otherwise the operator increments `start` and continues as if the most
148
- recent match was not a zero-length match.
 
 
 
 
 
 
149
 
150
  If the most recent match was not a zero-length match, the operator sets
151
- `flags` to `flags `|` regex_constants ``match_prev_avail` and calls
152
  `regex_search(start, end, match, *pregex, flags)`. If the call returns
153
  `false` the iterator sets `*this` to the end-of-sequence iterator. The
154
  iterator then returns `*this`.
155
 
156
  In all cases in which the call to `regex_search` returns `true`,
157
  `match.prefix().first` shall be equal to the previous value of
158
  `match[0].second`, and for each index `i` in the half-open range
159
- `[0, match.size())` for which `match[i].matched` is true,
160
- `match[i].position()` shall return `distance(begin, match[i].first)`.
161
 
162
- This means that `match[i].position()` gives the offset from the
163
- beginning of the target sequence, which is often not the same as the
164
- offset from the sequence passed in the call to `regex_search`.
 
165
 
166
  It is unspecified how the implementation makes these adjustments.
167
 
168
- This means that a compiler may call an implementation-specific search
169
- function, in which case a user-defined specialization of `regex_search`
170
- will not be called.
171
 
172
  ``` cpp
173
  regex_iterator operator++(int);
174
  ```
175
 
176
- *Effects:*
177
 
178
  ``` cpp
179
  regex_iterator tmp = *this;
180
  ++(*this);
181
  return tmp;
@@ -227,39 +234,38 @@ is not equal to a non-end-of-sequence iterator. Two non-end-of-sequence
227
  iterators are equal when they are constructed from the same arguments.
228
 
229
  ``` cpp
230
  namespace std {
231
  template <class BidirectionalIterator,
232
- class charT = typename iterator_traits<
233
- BidirectionalIterator>::value_type,
234
  class traits = regex_traits<charT>>
235
  class regex_token_iterator {
236
  public:
237
- typedef basic_regex<charT, traits> regex_type;
238
- typedef sub_match<BidirectionalIterator> value_type;
239
- typedef std::ptrdiff_t difference_type;
240
- typedef const value_type* pointer;
241
- typedef const value_type& reference;
242
- typedef std::forward_iterator_tag iterator_category;
243
 
244
  regex_token_iterator();
245
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
246
  const regex_type& re,
247
  int submatch = 0,
248
  regex_constants::match_flag_type m =
249
  regex_constants::match_default);
250
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
251
  const regex_type& re,
252
- const std::vector<int>& submatches,
253
  regex_constants::match_flag_type m =
254
  regex_constants::match_default);
255
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
256
  const regex_type& re,
257
  initializer_list<int> submatches,
258
  regex_constants::match_flag_type m =
259
  regex_constants::match_default);
260
- template <std::size_t N>
261
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
262
  const regex_type& re,
263
  const int (&submatches)[N],
264
  regex_constants::match_flag_type m =
265
  regex_constants::match_default);
@@ -268,19 +274,19 @@ namespace std {
268
  int submatch = 0,
269
  regex_constants::match_flag_type m =
270
  regex_constants::match_default) = delete;
271
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
272
  const regex_type&& re,
273
- const std::vector<int>& submatches,
274
  regex_constants::match_flag_type m =
275
  regex_constants::match_default) = delete;
276
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
277
  const regex_type&& re,
278
  initializer_list<int> submatches,
279
  regex_constants::match_flag_type m =
280
  regex_constants::match_default) = delete;
281
- template <std::size_t N>
282
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
283
  const regex_type&& re,
284
  const int (&submatches)[N],
285
  regex_constants::match_flag_type m =
286
  regex_constants::match_default) = delete;
@@ -290,18 +296,19 @@ namespace std {
290
  bool operator!=(const regex_token_iterator&) const;
291
  const value_type& operator*() const;
292
  const value_type* operator->() const;
293
  regex_token_iterator& operator++();
294
  regex_token_iterator operator++(int);
 
295
  private:
296
- typedef
297
- regex_iterator<BidirectionalIterator, charT, traits> position_iterator; // exposition only
298
  position_iterator position; // exposition only
299
  const value_type* result; // exposition only
300
  value_type suffix; // exposition only
301
- std::size_t N; // exposition only
302
- std::vector<int> subs; // exposition only
303
  };
304
  }
305
  ```
306
 
307
  A *suffix iterator* is a `regex_token_iterator` object that points to a
@@ -309,13 +316,13 @@ final sequence of characters at the end of the target sequence. In a
309
  suffix iterator the member `result` holds a pointer to the data member
310
  `suffix`, the value of the member `suffix.match` is `true`,
311
  `suffix.first` points to the beginning of the final sequence, and
312
  `suffix.second` points to the end of the final sequence.
313
 
314
- For a suffix iterator, data member `suffix.first` is the same as the end
315
- of the last match found, and `suffix.second` is the same as the end of
316
- the target sequence
317
 
318
  The *current match* is `(*position).prefix()` if `subs[N] == -1`, or
319
  `(*position)[subs[N]]` for any other value of `subs[N]`.
320
 
321
  #### `regex_token_iterator` constructors <a id="re.tokiter.cnstr">[[re.tokiter.cnstr]]</a>
@@ -328,31 +335,27 @@ regex_token_iterator();
328
 
329
  ``` cpp
330
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
331
  const regex_type& re,
332
  int submatch = 0,
333
- regex_constants::match_flag_type m =
334
- regex_constants::match_default);
335
 
336
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
337
  const regex_type& re,
338
- const std::vector<int>& submatches,
339
- regex_constants::match_flag_type m =
340
- regex_constants::match_default);
341
 
342
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
343
  const regex_type& re,
344
  initializer_list<int> submatches,
345
- regex_constants::match_flag_type m =
346
- regex_constants::match_default);
347
 
348
- template <std::size_t N>
349
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
350
  const regex_type& re,
351
  const int (&submatches)[N],
352
- regex_constants::match_flag_type m =
353
- regex_constants::match_default);
354
  ```
355
 
356
  *Requires:* Each of the initialization values of `submatches` shall be
357
  `>= -1`.
358
 
 
24
  iterators are equal when they are constructed from the same arguments.
25
 
26
  ``` cpp
27
  namespace std {
28
  template <class BidirectionalIterator,
29
+ class charT = typename iterator_traits<BidirectionalIterator>::value_type,
 
30
  class traits = regex_traits<charT>>
31
  class regex_iterator {
32
  public:
33
+ using regex_type = basic_regex<charT, traits>;
34
+ using iterator_category = forward_iterator_tag;
35
+ using value_type = match_results<BidirectionalIterator>;
36
+ using difference_type = ptrdiff_t;
37
+ using pointer = const value_type*;
38
+ using reference = const value_type&;
39
 
40
  regex_iterator();
41
  regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
42
  const regex_type& re,
43
+ regex_constants::match_flag_type m = regex_constants::match_default);
44
+ regex_iterator(BidirectionalIterator, BidirectionalIterator,
45
+ const regex_type&&,
46
+ regex_constants::match_flag_type = regex_constants::match_default) = delete;
 
 
47
  regex_iterator(const regex_iterator&);
48
  regex_iterator& operator=(const regex_iterator&);
49
  bool operator==(const regex_iterator&) const;
50
  bool operator!=(const regex_iterator&) const;
51
  const value_type& operator*() const;
52
  const value_type* operator->() const;
53
  regex_iterator& operator++();
54
  regex_iterator operator++(int);
55
+
56
  private:
57
  BidirectionalIterator begin; // exposition only
58
  BidirectionalIterator end; // exposition only
59
  const regex_type* pregex; // exposition only
60
  regex_constants::match_flag_type flags; // exposition only
 
63
  }
64
  ```
65
 
66
  An object of type `regex_iterator` that is not an end-of-sequence
67
  iterator holds a *zero-length match* if `match[0].matched == true` and
68
+ `match[0].first == match[0].second`.
69
+
70
+ [*Note 1*: For example, this can occur when the part of the regular
71
+ expression that matched consists only of an assertion (such as `'^'`,
72
+ `'$'`, `'\b'`, `'\B'`). — *end note*]
73
 
74
  #### `regex_iterator` constructors <a id="re.regiter.cnstr">[[re.regiter.cnstr]]</a>
75
 
76
  ``` cpp
77
  regex_iterator();
 
139
 
140
  If the iterator holds a zero-length match and `start == end` the
141
  operator sets `*this` to the end-of-sequence iterator and returns
142
  `*this`.
143
 
144
+ Otherwise, if the iterator holds a zero-length match, the operator
145
+ calls:
146
+
147
+ ``` cpp
148
+ regex_search(start, end, match, *pregex,
149
+ flags | regex_constants::match_not_null | regex_constants::match_continuous)
150
+ ```
151
+
152
+ If the call returns `true` the operator returns `*this`. Otherwise the
153
+ operator increments `start` and continues as if the most recent match
154
+ was not a zero-length match.
155
 
156
  If the most recent match was not a zero-length match, the operator sets
157
+ `flags` to `flags | regex_constants::match_prev_avail` and calls
158
  `regex_search(start, end, match, *pregex, flags)`. If the call returns
159
  `false` the iterator sets `*this` to the end-of-sequence iterator. The
160
  iterator then returns `*this`.
161
 
162
  In all cases in which the call to `regex_search` returns `true`,
163
  `match.prefix().first` shall be equal to the previous value of
164
  `match[0].second`, and for each index `i` in the half-open range
165
+ `[0, match.size())` for which `match[i].matched` is `true`,
166
+ `match.position(i)` shall return `distance(begin, match[i].first)`.
167
 
168
+ [*Note 1*: This means that `match.position(i)` gives the offset from
169
+ the beginning of the target sequence, which is often not the same as the
170
+ offset from the sequence passed in the call to
171
+ `regex_search`. — *end note*]
172
 
173
  It is unspecified how the implementation makes these adjustments.
174
 
175
+ [*Note 2*: This means that a compiler may call an
176
+ implementation-specific search function, in which case a user-defined
177
+ specialization of `regex_search` will not be called. — *end note*]
178
 
179
  ``` cpp
180
  regex_iterator operator++(int);
181
  ```
182
 
183
+ *Effects:* As if by:
184
 
185
  ``` cpp
186
  regex_iterator tmp = *this;
187
  ++(*this);
188
  return tmp;
 
234
  iterators are equal when they are constructed from the same arguments.
235
 
236
  ``` cpp
237
  namespace std {
238
  template <class BidirectionalIterator,
239
+ class charT = typename iterator_traits<BidirectionalIterator>::value_type,
 
240
  class traits = regex_traits<charT>>
241
  class regex_token_iterator {
242
  public:
243
+ using regex_type = basic_regex<charT, traits>;
244
+ using iterator_category = forward_iterator_tag;
245
+ using value_type = sub_match<BidirectionalIterator>;
246
+ using difference_type = ptrdiff_t;
247
+ using pointer = const value_type*;
248
+ using reference = const value_type&;
249
 
250
  regex_token_iterator();
251
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
252
  const regex_type& re,
253
  int submatch = 0,
254
  regex_constants::match_flag_type m =
255
  regex_constants::match_default);
256
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
257
  const regex_type& re,
258
+ const vector<int>& submatches,
259
  regex_constants::match_flag_type m =
260
  regex_constants::match_default);
261
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
262
  const regex_type& re,
263
  initializer_list<int> submatches,
264
  regex_constants::match_flag_type m =
265
  regex_constants::match_default);
266
+ template <size_t N>
267
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
268
  const regex_type& re,
269
  const int (&submatches)[N],
270
  regex_constants::match_flag_type m =
271
  regex_constants::match_default);
 
274
  int submatch = 0,
275
  regex_constants::match_flag_type m =
276
  regex_constants::match_default) = delete;
277
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
278
  const regex_type&& re,
279
+ const vector<int>& submatches,
280
  regex_constants::match_flag_type m =
281
  regex_constants::match_default) = delete;
282
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
283
  const regex_type&& re,
284
  initializer_list<int> submatches,
285
  regex_constants::match_flag_type m =
286
  regex_constants::match_default) = delete;
287
+ template <size_t N>
288
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
289
  const regex_type&& re,
290
  const int (&submatches)[N],
291
  regex_constants::match_flag_type m =
292
  regex_constants::match_default) = delete;
 
296
  bool operator!=(const regex_token_iterator&) const;
297
  const value_type& operator*() const;
298
  const value_type* operator->() const;
299
  regex_token_iterator& operator++();
300
  regex_token_iterator operator++(int);
301
+
302
  private:
303
+ using position_iterator =
304
+ regex_iterator<BidirectionalIterator, charT, traits>; // exposition only
305
  position_iterator position; // exposition only
306
  const value_type* result; // exposition only
307
  value_type suffix; // exposition only
308
+ size_t N; // exposition only
309
+ vector<int> subs; // exposition only
310
  };
311
  }
312
  ```
313
 
314
  A *suffix iterator* is a `regex_token_iterator` object that points to a
 
316
  suffix iterator the member `result` holds a pointer to the data member
317
  `suffix`, the value of the member `suffix.match` is `true`,
318
  `suffix.first` points to the beginning of the final sequence, and
319
  `suffix.second` points to the end of the final sequence.
320
 
321
+ [*Note 1*: For a suffix iterator, data member `suffix.first` is the
322
+ same as the end of the last match found, and `suffix.second` is the same
323
+ as the end of the target sequence — *end note*]
324
 
325
  The *current match* is `(*position).prefix()` if `subs[N] == -1`, or
326
  `(*position)[subs[N]]` for any other value of `subs[N]`.
327
 
328
  #### `regex_token_iterator` constructors <a id="re.tokiter.cnstr">[[re.tokiter.cnstr]]</a>
 
335
 
336
  ``` cpp
337
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
338
  const regex_type& re,
339
  int submatch = 0,
340
+ regex_constants::match_flag_type m = regex_constants::match_default);
 
341
 
342
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
343
  const regex_type& re,
344
+ const vector<int>& submatches,
345
+ regex_constants::match_flag_type m = regex_constants::match_default);
 
346
 
347
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
348
  const regex_type& re,
349
  initializer_list<int> submatches,
350
+ regex_constants::match_flag_type m = regex_constants::match_default);
 
351
 
352
+ template <size_t N>
353
  regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
354
  const regex_type& re,
355
  const int (&submatches)[N],
356
+ regex_constants::match_flag_type m = regex_constants::match_default);
 
357
  ```
358
 
359
  *Requires:* Each of the initialization values of `submatches` shall be
360
  `>= -1`.
361