Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Increments the iterator.

regex_iterator& operator++();
regex_iterator& operator++(int);

If the current match has no characters the first operator calls regex_search(begin, end, match, *pregex, flags | regex_constants::match_prev_avail | regex_constants::match_not_null); otherwise it advances the stored value begin to point to the first character after the current match then calls regex_search(begin, end, match, *pregex, flags | regex_constants::match_prev_avail). In either case, if the search fails the operator sets the object to an end-of-sequence iterator. The operator returns the object.

The second operator makes a copy of the object, increments the object, then returns the copy.


// std_tr1__regex__regex_iterator_operator_inc.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
typedef std::tr1::regex_iterator<const char *> Myiter; 
int main() 
    const char *pat = "axayaz"; 
    Myiter::regex_type rx("a"); 
    Myiter next(pat, pat + strlen(pat), rx); 
    Myiter end; 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
// other members 
    Myiter it1(pat, pat + strlen(pat), rx); 
    Myiter it2(it1); 
    next = it1; 
    Myiter::iterator_category cat = std::forward_iterator_tag(); 
    Myiter::difference_type dif = -3; 
    Myiter::value_type mr = *it1; 
    Myiter::reference ref = mr; 
    Myiter::pointer ptr = &ref; 
    dif = dif; // to quiet "unused" warnings 
    ptr = ptr; 
    return (0); 
match == a match == a match == a

Header: <regex>

Namespace: std::tr1

© 2016 Microsoft