Namespaces
Variants

Standard library header <exception>

From cppreference.net
Standard library headers

Dieser Header ist Teil der Fehlerbehandlungsbibliothek .

Inhaltsverzeichnis

Typen

Basisklasse für Ausnahmen, die von den Komponenten der Standardbibliothek geworfen werden
(Klasse)
Ein Mixin-Typ zum Erfassen und Speichern aktueller Exceptions
(Klasse)
Exception, die ausgelöst wird, wenn std::current_exception das Exception-Objekt nicht kopieren kann
(Klasse)
(in C++11 veraltet) (in C++17 entfernt)
der Typ der Funktion, die von std::unexpected aufgerufen wird
(Typdefinition)
der Typ der Funktion, die von std::terminate aufgerufen wird
(typedef)
Gemeinsamer Zeigertyp zur Behandlung von Ausnahmeobjekten
(typedef)

Funktionen

(deprecated in C++11) (removed in C++17)
Funktion, die aufgerufen wird, wenn eine dynamische Exception-Spezifikation verletzt wird
(Funktion)
( removed in C++20* ) (C++17)
prüft, ob aktuell eine Ausnahmebehandlung stattfindet
(Funktion)
erstellt einen std::exception_ptr aus einem Exception-Objekt
(Funktionstemplate)
erfasst die aktuelle Ausnahme in einem std::exception_ptr
(Funktion)
wirft die Ausnahme von einem std::exception_ptr
(Funktion)
wirft sein Argument mit std::nested_exception vermischt
(Funktions-Template)
wirft die Exception aus einer std::nested_exception
(Funktions-Template)
Funktion, die aufgerufen wird, wenn die Ausnahmebehandlung fehlschlägt
(Funktion)
ermittelt den aktuellen terminate_handler
(Funktion)
ändert die Funktion, die von std::terminate aufgerufen wird
(Funktion)
(in C++11 veraltet) (in C++17 entfernt)
ermittelt den aktuellen unexpected_handler
(Funktion)
(in C++11 veraltet) (in C++17 entfernt)
ändert die Funktion, die von std::unexpected aufgerufen wird
(Funktion)

Synopsis

// alle freistehend
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 = /* unspecified */;
  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);
}

Klasse 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;
  };
}

Klasse std::bad_exception

namespace std {
  class bad_exception : public exception
  {
  public:
    // siehe Beschreibung für die Spezifikation der speziellen Elementfunktionen
    constexpr const char* what() const noexcept override;
  };
}

Klasse 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;
    // Zugriffsfunktionen
    [[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);
}

Siehe auch