std:: regex_error
From cppreference.net
|
ヘッダーで定義
<regex>
|
||
|
class
regex_error
;
|
(C++11以降) | |
正規表現ライブラリでエラーを報告するためにスローされる例外オブジェクトの型を定義します。
継承図
目次 |
メンバー関数
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]
|
説明文字列を返す
(
std::exception
の仮想公開メンバ関数)
|
例
このコードを実行
#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