Namespaces
Variants

Standard library header <exception>

From cppreference.net
Standard library headers

이 헤더는 error handling 라이브러리의 일부입니다.

목차

타입

표준 라이브러리 구성 요소에서 발생하는 예외의 기본 클래스
(class)
현재 예외를 캡처하고 저장하기 위한 믹스인 타입
(클래스)
예외 객체 복사에 실패할 때 std::current_exception 이 던지는 예외
(클래스)
(C++11에서 사용 중단됨) (C++17에서 제거됨)
std::unexpected 에 의해 호출되는 함수의 타입
(typedef)
std::terminate 에 의해 호출되는 함수의 타입
(typedef)
예외 객체를 처리하기 위한 공유 포인터 타입
(typedef)

함수

(C++11에서 사용 중단됨) (C++17에서 제거됨)
동적 예외 사양이 위반될 때 호출되는 함수
(함수)
( removed in C++20* ) (C++17)
예외 처리가 현재 진행 중인지 확인합니다
(function)
예외 객체로부터 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 에 의해 호출될 함수를 변경합니다
(함수)

시놉시스

// all freestanding
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);
}

클래스 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);
}

참고 항목