Share via


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::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

See Also

Reference

<regex>

sub_match Class