名前空間
変種
操作

std::regex_error

From cppreference.com
< cpp‎ | regex
 
 
 
正規表現ライブラリ
クラス
(C++11)
アルゴリズム
イテレータ
例外
regex_error
(C++11)
Traits
定数
(C++11)
正規表現文法
 
 
ヘッダ <regex> で定義
class regex_error;
(C++11以降)

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

cpp/error/exceptioncpp/error/runtime errorstd-regex error-inheritance.svg

継承図

目次

[編集] メンバ関数

regex_error オブジェクトを構築します
(public member function) [編集]
regex_error オブジェクトを置き換えます
(public member function) [編集]
regex_errorstd::regex_constants::error_type を取得します
(public member function) [編集]

std::runtime_error から継承


std::exception から継承

メンバ関数

例外オブジェクトを破棄する
(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
English 日本語 中文(简体) 中文(繁體)