Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

operator<< <regex>

 

Inserts a sub_match in a stream.

template<class Elem, class IOtraits, class Alloc, class BidIt>
    basic_ostream<Elem, IOtraits>&
    operator<<(basic_ostream<Elem, IOtraits>& os,
        const sub_match<BidIt>& right);

Elem

The element type.

IOtraits

The string traits class.

Alloc

The allocator class.

BidIt

The iterator type.

os

The output stream.

right

The object to insert.

The template operator returns os << right.str().

Example

 

// std_tr1__regex__operator_ins.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 

int main() 
    { 
    std::regex rx("c(a*)|(b)"); 
    std::cmatch mr; 

    std::regex_search("xcaaay", mr, rx); 

    std::csub_match sub = mr[0]; 
    std::cout << "whole match: " << sub << std::endl; 

    return (0); 
    } 

whole match: caaa

Requirements

Header: <regex>

Namespace: std

Show: