Spec-Zone.ru › C++

Стандартная библиотека заголовок <exception>

Этот заголовок является частью библиотеки обработки ошибок.

Типы

exception
базовый класс для исключений, выбрасываемых компонентами стандартной библиотеки
(класс)
nested_exception
(C++11)
тип-микшин для захвата и хранения текущих исключений
(класс)
bad_exception
исключение, выбрасываемое, когда std::current_exception не удаётся скопировать объект исключения
(класс)
unexpected_handler
(удалено в C++17)
тип функции, вызываемой std::unexpected
(typedef)
terminate_handler
тип функции, вызываемой std::terminate
(typedef)
exception_ptr
(C++11)
тип разделяемой ссылки для обработки объектов исключений
(typedef)

Функции

unexpected
(удалено в C++17)
функция, вызываемая при нарушении динамической спецификации исключения
(функция)
uncaught_exceptionuncaught_exceptions
(удалено в C++20)(C++17)
проверяет, находится ли в данный момент в процессе обработки исключений
(функция)
make_exception_ptr
(C++11)
создаёт std::exception_ptr из объекта исключения
(функция-шаблон)
current_exception
(C++11)
захватывает текущее исключение в std::exception_ptr
(функция)
rethrow_exception
(C++11)
выбрасывает исключение из std::exception_ptr
(функция)
throw_with_nested
(C++11)
выбрасывает свой аргумент с std::nested_exception
(функция-шаблон)
rethrow_if_nested
(C++11)
выбрасывает исключение из std::nested_exception
(функция-шаблон)
terminate
функция, вызываемая при неудачной обработке исключения
(функция)
get_terminate
(C++11)
получает текущий terminate_handler
(функция)
set_terminate
изменяет функцию, которая вызывается std::terminate
(функция)
get_unexpected
(C++11)(удалено в C++17)
получает текущий unexpected_handler
(функция)
set_unexpected
(удалено в 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;
 
  int uncaught_exceptions() noexcept;
 
  using exception_ptr = /* unspecified */;
 
  exception_ptr current_exception() noexcept;
  [[noreturn]] void rethrow_exception(exception_ptr p);
  template<class E> exception_ptr make_exception_ptr(E e) noexcept;
 
  template<class T> [[noreturn]] void throw_with_nested(T&& t);
  template<class E> void rethrow_if_nested(const E& e);
}

Класс std::exception

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

Класс std::bad_exception

namespace std {
  class bad_exception : public exception {
  public:
    // see [exception] for the specification of the special member functions
    const char* what() const noexcept override;
  };
}

Класс std::nested_exception

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

См. также

  • Обработка ошибок

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/header/exception

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API