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);

Parameters

  • 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.

Remarks

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

Example

 

// std_tr1__regex__operator_ins.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
int main() 
    { 
    std::tr1::regex rx("c(a*)|(b)"); 
    std::tr1::cmatch mr; 
 
    std::tr1::regex_search("xcaaay", mr, rx); 
 
    std::tr1::csub_match sub = mr[0]; 
    std::cout << "whole match: " << sub << std::endl; 
 
    return (0); 
    } 
 

whole match: caaa

Requirements

Header: <regex>

Namespace: std::tr1

See Also

Reference

<regex>

sub_match Class