名前空間
変種
操作

std::regex_error

提供: cppreference.com
< cpp‎ | regex
ヘッダ <regex> で定義
class regex_error;
(C++11以上)

正規表現ライブラリのエラーを報告するために投げられる例外オブジェクトの型を定義します。

cpp/error/exceptioncpp/error/runtime errorstd-regex error-inheritance.svg
画像の詳細

継承図

目次

[編集]メンバ関数

regex_error オブジェクトを構築します
(パブリックメンバ関数)[edit]
regex_error のための std::regex_constants::error_type を取得します
(パブリックメンバ関数)[edit]

std::exception から継承

メンバ関数

例外オブジェクトを破棄します
(std::exceptionの仮想パブリックメンバ関数)[edit]
[仮想]
説明文字列を返します
(std::exceptionの仮想パブリックメンバ関数)[edit]

[編集]

#include <regex>#include <iostream>   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
close