Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
regex_error::regex_error
Collapse the table of content
Expand the table of content

regex_error::regex_error

Constructs the object.

regex_error(regex_constants::error_code error);

error

The error code.

The constructor constructs an object that holds the value error.

 

// std_tr1__regex__regex_error_construct.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
int main() 
    { 
    std::tr1::regex_error paren(std::tr1::regex_constants::error_paren); 
 
    try 
        { 
        std::tr1::regex rx("(a"); 
        } 
    catch (const std::tr1::regex_error& rerr) 
        { 
        std::cout << "regex error: " 
            << (rerr.code() == paren.code() 
                ? "unbalanced parentheses" : "?") 
            << std::endl; 
        } 
    catch (...) 
        { 
        std::cout << "unknown exception" << std::endl; 
        } 
 
    return (0); 
    } 
 
regex error: unbalanced parentheses

Header: <regex>

Namespace: std::tr1

Community Additions

ADD
Show:
© 2015 Microsoft