tmp/tmpfy4a1_3p/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="re.tokiter.general">[[re.tokiter.general]]</a>
|
| 2 |
+
|
| 3 |
+
The class template `regex_token_iterator` is an iterator adaptor; that
|
| 4 |
+
is to say it represents a new view of an existing iterator sequence, by
|
| 5 |
+
enumerating all the occurrences of a regular expression within that
|
| 6 |
+
sequence, and presenting one or more sub-expressions for each match
|
| 7 |
+
found. Each position enumerated by the iterator is a `sub_match` class
|
| 8 |
+
template instance that represents what matched a particular
|
| 9 |
+
sub-expression within the regular expression.
|
| 10 |
+
|
| 11 |
+
When class `regex_token_iterator` is used to enumerate a single
|
| 12 |
+
sub-expression with index -1 the iterator performs field splitting: that
|
| 13 |
+
is to say it enumerates one sub-expression for each section of the
|
| 14 |
+
character container sequence that does not match the regular expression
|
| 15 |
+
specified.
|
| 16 |
+
|
| 17 |
+
After it is constructed, the iterator finds and stores a value
|
| 18 |
+
`regex_iterator<BidirectionalIterator> position` and sets the internal
|
| 19 |
+
count `N` to zero. It also maintains a sequence `subs` which contains a
|
| 20 |
+
list of the sub-expressions which will be enumerated. Every time
|
| 21 |
+
`operator++` is used the count `N` is incremented; if `N` exceeds or
|
| 22 |
+
equals `subs.size()`, then the iterator increments member `position` and
|
| 23 |
+
sets count `N` to zero.
|
| 24 |
+
|
| 25 |
+
If the end of sequence is reached (`position` is equal to the end of
|
| 26 |
+
sequence iterator), the iterator becomes equal to the end-of-sequence
|
| 27 |
+
iterator value, unless the sub-expression being enumerated has index -1,
|
| 28 |
+
in which case the iterator enumerates one last sub-expression that
|
| 29 |
+
contains all the characters from the end of the last regular expression
|
| 30 |
+
match to the end of the input sequence being enumerated, provided that
|
| 31 |
+
this would not be an empty sub-expression.
|
| 32 |
+
|
| 33 |
+
The default constructor constructs an end-of-sequence iterator object,
|
| 34 |
+
which is the only legitimate iterator to be used for the end condition.
|
| 35 |
+
The result of `operator*` on an end-of-sequence iterator is not defined.
|
| 36 |
+
For any other iterator value a `const sub_match<BidirectionalIterator>&`
|
| 37 |
+
is returned. The result of `operator->` on an end-of-sequence iterator
|
| 38 |
+
is not defined. For any other iterator value a `const
|
| 39 |
+
sub_match<BidirectionalIterator>*` is returned.
|
| 40 |
+
|
| 41 |
+
It is impossible to store things into `regex_token_iterator`s. Two
|
| 42 |
+
end-of-sequence iterators are always equal. An end-of-sequence iterator
|
| 43 |
+
is not equal to a non-end-of-sequence iterator. Two non-end-of-sequence
|
| 44 |
+
iterators are equal when they are constructed from the same arguments.
|
| 45 |
+
|
| 46 |
+
``` cpp
|
| 47 |
+
namespace std {
|
| 48 |
+
template<class BidirectionalIterator,
|
| 49 |
+
class charT = typename iterator_traits<BidirectionalIterator>::value_type,
|
| 50 |
+
class traits = regex_traits<charT>>
|
| 51 |
+
class regex_token_iterator {
|
| 52 |
+
public:
|
| 53 |
+
using regex_type = basic_regex<charT, traits>;
|
| 54 |
+
using iterator_category = forward_iterator_tag;
|
| 55 |
+
using iterator_concept = input_iterator_tag;
|
| 56 |
+
using value_type = sub_match<BidirectionalIterator>;
|
| 57 |
+
using difference_type = ptrdiff_t;
|
| 58 |
+
using pointer = const value_type*;
|
| 59 |
+
using reference = const value_type&;
|
| 60 |
+
|
| 61 |
+
regex_token_iterator();
|
| 62 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 63 |
+
const regex_type& re,
|
| 64 |
+
int submatch = 0,
|
| 65 |
+
regex_constants::match_flag_type m =
|
| 66 |
+
regex_constants::match_default);
|
| 67 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 68 |
+
const regex_type& re,
|
| 69 |
+
const vector<int>& submatches,
|
| 70 |
+
regex_constants::match_flag_type m =
|
| 71 |
+
regex_constants::match_default);
|
| 72 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 73 |
+
const regex_type& re,
|
| 74 |
+
initializer_list<int> submatches,
|
| 75 |
+
regex_constants::match_flag_type m =
|
| 76 |
+
regex_constants::match_default);
|
| 77 |
+
template<size_t N>
|
| 78 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 79 |
+
const regex_type& re,
|
| 80 |
+
const int (&submatches)[N],
|
| 81 |
+
regex_constants::match_flag_type m =
|
| 82 |
+
regex_constants::match_default);
|
| 83 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 84 |
+
const regex_type&& re,
|
| 85 |
+
int submatch = 0,
|
| 86 |
+
regex_constants::match_flag_type m =
|
| 87 |
+
regex_constants::match_default) = delete;
|
| 88 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 89 |
+
const regex_type&& re,
|
| 90 |
+
const vector<int>& submatches,
|
| 91 |
+
regex_constants::match_flag_type m =
|
| 92 |
+
regex_constants::match_default) = delete;
|
| 93 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 94 |
+
const regex_type&& re,
|
| 95 |
+
initializer_list<int> submatches,
|
| 96 |
+
regex_constants::match_flag_type m =
|
| 97 |
+
regex_constants::match_default) = delete;
|
| 98 |
+
template<size_t N>
|
| 99 |
+
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
| 100 |
+
const regex_type&& re,
|
| 101 |
+
const int (&submatches)[N],
|
| 102 |
+
regex_constants::match_flag_type m =
|
| 103 |
+
regex_constants::match_default) = delete;
|
| 104 |
+
regex_token_iterator(const regex_token_iterator&);
|
| 105 |
+
regex_token_iterator& operator=(const regex_token_iterator&);
|
| 106 |
+
bool operator==(const regex_token_iterator&) const;
|
| 107 |
+
bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); }
|
| 108 |
+
const value_type& operator*() const;
|
| 109 |
+
const value_type* operator->() const;
|
| 110 |
+
regex_token_iterator& operator++();
|
| 111 |
+
regex_token_iterator operator++(int);
|
| 112 |
+
|
| 113 |
+
private:
|
| 114 |
+
using position_iterator =
|
| 115 |
+
regex_iterator<BidirectionalIterator, charT, traits>; // exposition only
|
| 116 |
+
position_iterator position; // exposition only
|
| 117 |
+
const value_type* result; // exposition only
|
| 118 |
+
value_type suffix; // exposition only
|
| 119 |
+
size_t N; // exposition only
|
| 120 |
+
vector<int> subs; // exposition only
|
| 121 |
+
};
|
| 122 |
+
}
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
A *suffix iterator* is a `regex_token_iterator` object that points to a
|
| 126 |
+
final sequence of characters at the end of the target sequence. In a
|
| 127 |
+
suffix iterator the member `result` holds a pointer to the data member
|
| 128 |
+
`suffix`, the value of the member `suffix.match` is `true`,
|
| 129 |
+
`suffix.first` points to the beginning of the final sequence, and
|
| 130 |
+
`suffix.second` points to the end of the final sequence.
|
| 131 |
+
|
| 132 |
+
[*Note 1*: For a suffix iterator, data member `suffix.first` is the
|
| 133 |
+
same as the end of the last match found, and `suffix.second` is the same
|
| 134 |
+
as the end of the target sequence. — *end note*]
|
| 135 |
+
|
| 136 |
+
The *current match* is `(*position).prefix()` if `subs[N] == -1`, or
|
| 137 |
+
`(*position)[subs[N]]` for any other value of `subs[N]`.
|
| 138 |
+
|