名前空間
変種
操作

std::bad_exception

提供: cppreference.com
< cpp‎ | error
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ(C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
 
 
ヘッダ <exception> で定義
class bad_exception;

std::bad_exception は以下の状況で C++ ランタイムによって投げられる例外の型です。

  • std::exception_ptr がキャッチされた例外のコピーを格納し、 std::current_exception によってキャッチされた例外オブジェクトのコピーコンストラクタが例外を投げた場合、キャプチャされる例外は std::bad_exception のインスタンスです。
(C++11以上)
  • 動的例外指定に違反し、 std::unexpected がその例外指定に違反する例外を投げたとき、その例外指定で std::bad_exception が許可されていれば、 std::bad_exception が投げられます。
(C++17未満)
cpp/error/exceptionstd-bad exception-inheritance.svg
画像の詳細

継承図

目次

[編集]メンバ関数

bad_exception オブジェクトを構築します
(パブリックメンバ関数)
オブジェクトをコピーします
(パブリックメンバ関数)
[仮想]
説明文字列を返します
(仮想パブリックメンバ関数)

std::exception から継承

メンバ関数

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

[編集]

#include <iostream>#include <exception>#include <stdexcept>   void my_unexp(){throw;}   void test()throw(std::bad_exception){throwstd::runtime_error("test");}   int main(){std::set_unexpected(my_unexp);try{ test();}catch(const std::bad_exception& e){std::cerr<<"Caught "<< e.what()<<'\n';}}

出力例:

Caught std::bad_exception
close