std::regex_error
From cppreference.com
| ヘッダ <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 の仮想 public メンバー関数) |
| [virtual] |
説明文字列を返す ( std::exception の仮想 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