Namespaces
Variants

std:: regex_error

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
regex_error
(C++11)
Traits
Constants
(C++11)
Regex Grammar
헤더 파일에 정의됨 <regex>
class regex_error ;
(C++11부터)

정규 표현식 라이브러리에서 오류를 보고하기 위해 던져지는 예외 객체의 유형을 정의합니다.

cpp/error/exception cpp/error/runtime error std-regex error-inheritance.svg

상속 다이어그램

목차

멤버 함수

regex_error 객체를 생성합니다
(public member function)
regex_error 객체를 대체합니다
(public member function)
regex_error std::regex_constants::error_type 를 반환합니다
(public member function)

std:: runtime_error 에서 상속됨


std:: exception 에서 상속됨

멤버 함수

[virtual]
예외 객체를 파괴함
( std::exception 의 virtual public 멤버 함수)
[virtual]
설명 문자열을 반환함
( std::exception 의 virtual public 멤버 함수)

예제

#include <iostream>
#include <regex>
int main()
{
    try
    {
        std::regex re("[a-b][a");
    }
    catch (const std::regex_error& e)
    {
        std::cout << "regex_error caught: " << e.what() << '\n';
        if (e.code() == std::regex_constants::error_brack)
            std::cout << "The code was error_brack\n";
    }
}

가능한 출력:

regex_error caught: The expression contained mismatched [ and ].
The code was error_brack