description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | |||
---|---|---|---|---|---|---|---|---|
Learn more about: regex_error Class |
regex_error Class |
09/10/2018 |
|
|
3333a1a3-ca6f-4612-84b2-1b4c7e3db5a4 |
Reports a bad basic_regex object.
class regex_error
: public std::runtime_error
The class describes an exception object thrown to report an error in the construction or use of a basic_regex
object.
Constructor | Description |
---|---|
regex_error | Constructs the object. |
Member function | Description |
---|---|
code | Returns the error code. |
Header: <regex>
Namespace: std
// std__regex__regex_error.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
int main()
{
std::regex_error paren(std::regex_constants::error_paren);
try
{
std::regex rx("(a");
}
catch (const std::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
Returns the error code.
regex_constants::error_code code() const;
The member function returns the value that was passed to the object's constructor.
Constructs the object.
regex_error(regex_constants::error_code error);
error
The error code.
The constructor constructs an object that holds the value error.
<regex>
regex_constants Class
<regex> functions
regex_iterator Class
<regex> operators
regex_token_iterator Class
regex_traits Class
<regex> typedefs