Namespaces
Variants

Standard library header <exception>

From cppreference.net
Standard library headers

このヘッダは エラーハンドリング ライブラリの一部です。

目次

標準ライブラリコンポーネントによってスローされる例外の基底クラス
(クラス)
現在の例外を捕捉・保存するためのミックスイン型
(クラス)
例外オブジェクトのコピーに std::current_exception が失敗したときにスローされる例外
(クラス)
(C++11で非推奨) (C++17で削除)
std::unexpected によって呼び出される関数の型
(typedef)
std::terminate によって呼び出される関数の型
(typedef)
例外オブジェクトを扱うための共有ポインタ型
(typedef)

関数

(C++11で非推奨) (C++17で削除)
動的例外仕様が違反されたときに呼び出される関数
(関数)
( C++20で削除* ) (C++17)
例外処理が現在進行中かどうかをチェックする
(関数)
例外オブジェクトから std::exception_ptr を作成する
(関数テンプレート)
現在の例外を std::exception_ptr にキャプチャする
(関数)
std::exception_ptr から例外を送出する
(関数)
引数を std::nested_exception と共に送出する
(関数テンプレート)
std::nested_exception から例外をスローする
(関数テンプレート)
例外処理が失敗したときに呼び出される関数
(関数)
現在のterminate_handlerを取得する
(関数)
std::terminate によって呼び出される関数を変更する
(関数)
(C++11で非推奨) (C++17で削除)
現在の unexpected_handler を取得する
(関数)
(C++11で非推奨) (C++17で削除)
std::unexpected によって呼び出される関数を変更する
(関数)

概要

// すべてフリースタンディング環境向け
namespace std {
  class exception;
  class bad_exception;
  class nested_exception;
  using terminate_handler = void (*)();
  terminate_handler get_terminate() noexcept;
  terminate_handler set_terminate(terminate_handler f) noexcept;
  [[noreturn]] void terminate() noexcept;
  constexpr int uncaught_exceptions() noexcept;
  using exception_ptr = /* 未指定 */;
  constexpr exception_ptr current_exception() noexcept;
  [[noreturn]] constexpr void rethrow_exception(exception_ptr p);
  template<class E> constexpr exception_ptr make_exception_ptr(E e) noexcept;
  template<class T> [[noreturn]] constexpr void throw_with_nested(T&& t);
  template<class E> constexpr void rethrow_if_nested(const E& e);
}

クラス std::exception

namespace std {
  class exception
  {
  public:
    constexpr exception() noexcept;
    constexpr exception(const exception&) noexcept;
    constexpr exception& operator=(const exception&) noexcept;
    constexpr virtual ~exception();
    constexpr virtual const char* what() const noexcept;
  };
}

クラス std::bad_exception

namespace std {
  class bad_exception : public exception
  {
  public:
    // 特殊メンバ関数の仕様については説明を参照
    constexpr const char* what() const noexcept override;
  };
}

クラス std::nested_exception

namespace std {
  class nested_exception
  {
  public:
    constexpr nested_exception() noexcept;
    constexpr nested_exception(const nested_exception&) noexcept = default;
    constexpr nested_exception& operator=(const nested_exception&) noexcept = default;
    constexpr virtual ~nested_exception() = default;
    // アクセス関数
    [[noreturn]] constexpr void rethrow_nested() const;
    constexpr exception_ptr nested_ptr() const noexcept;
  };
  template<class T> [[noreturn]] constexpr void throw_with_nested(T&& t);
  template<class E> constexpr void rethrow_if_nested(const E& e);
}

関連項目