Export (0) Print
Expand All

regex_token_iterator::value_type

The type of a submatch.

typedef sub_match<BidIt> value_type;

The type is a synonym for sub_match<BidIt>, where BidIt is the template parameter.

 

// std_tr1__regex__regex_token_iterator_value_type.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
typedef std::tr1::regex_token_iterator<const char *> Myiter; 
int main() 
    { 
    const char *pat = "aaxaayaaz"; 
    Myiter::regex_type rx("(a)a"); 
    Myiter next(pat, pat + strlen(pat), rx); 
    Myiter end; 
 
// show whole match 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show prefix before match 
    next = Myiter(pat, pat + strlen(pat), rx, -1); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show (a) submatch only 
    next = Myiter(pat, pat + strlen(pat), rx, 1); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show prefixes and submatches 
    std::vector<int> vec; 
    vec.push_back(-1); 
    vec.push_back(1); 
    next = Myiter(pat, pat + strlen(pat), rx, vec); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << std::endl; 
 
// show prefixes and whole matches 
    int arr[] = {-1, 0}; 
    next = Myiter(pat, pat + strlen(pat), rx, arr); 
    for (; next != end; ++next) 
        std::cout << "match == " << next->str() << std::endl; 
    std::cout << 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 == aa match == aa match == aa match == match == x match == y match == z match == a match == a match == a match == match == a match == x match == a match == y match == a match == z match == match == aa match == x match == aa match == y match == aa match == z

Header: <regex>

Namespace: std::tr1

Community Additions

ADD
Show:
© 2014 Microsoft