cpp/regex/regex token iterator

is a read-only that accesses the individual sub-matches of every match of a regular expression within the underlying character sequence. It can also be used to access the parts of the sequence that were not matched by the given regular expression (e.g. as a tokenizer).

On construction, it constructs an std and on every increment it steps through the requested sub-matches from the current match_results, incrementing the underlying std when incrementing away from the last submatch.

The default-constructed is the end-of-sequence iterator. When a valid is incremented after reaching the last submatch of the last match, it becomes equal to the end-of-sequence iterator. Dereferencing or incrementing it further invokes undefined behavior.

Just before becoming the end-of-sequence iterator, a may become a suffix iterator, if the index  (non-matched fragment) appears in the list of the requested submatch indexes. Such iterator, if dereferenced, returns a match_results corresponding to the sequence of characters between the last match and the end of sequence.

A typical implementation of holds the underlying std, a container (e.g. ) of the requested submatch indexes, the internal counter equal to the index of the submatch, a pointer to std, pointing at the current submatch of the current match, and a std object containing the last non-matched character sequence (used in tokenizer mode).

Specializations
Several specializations for common character sequence types are defined: