xref: /freebsd/contrib/llvm-project/libcxx/include/exception (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric// -*- C++ -*-
2349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_EXCEPTION
110b57cec5SDimitry Andric#define _LIBCPP_EXCEPTION
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric    exception synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry Andricnamespace std
170b57cec5SDimitry Andric{
180b57cec5SDimitry Andric
190b57cec5SDimitry Andricclass exception
200b57cec5SDimitry Andric{
210b57cec5SDimitry Andricpublic:
220b57cec5SDimitry Andric    exception() noexcept;
230b57cec5SDimitry Andric    exception(const exception&) noexcept;
240b57cec5SDimitry Andric    exception& operator=(const exception&) noexcept;
250b57cec5SDimitry Andric    virtual ~exception() noexcept;
260b57cec5SDimitry Andric    virtual const char* what() const noexcept;
270b57cec5SDimitry Andric};
280b57cec5SDimitry Andric
290b57cec5SDimitry Andricclass bad_exception
300b57cec5SDimitry Andric    : public exception
310b57cec5SDimitry Andric{
320b57cec5SDimitry Andricpublic:
330b57cec5SDimitry Andric    bad_exception() noexcept;
340b57cec5SDimitry Andric    bad_exception(const bad_exception&) noexcept;
350b57cec5SDimitry Andric    bad_exception& operator=(const bad_exception&) noexcept;
360b57cec5SDimitry Andric    virtual ~bad_exception() noexcept;
370b57cec5SDimitry Andric    virtual const char* what() const noexcept;
380b57cec5SDimitry Andric};
390b57cec5SDimitry Andric
400b57cec5SDimitry Andrictypedef void (*unexpected_handler)();
410b57cec5SDimitry Andricunexpected_handler set_unexpected(unexpected_handler  f ) noexcept;
420b57cec5SDimitry Andricunexpected_handler get_unexpected() noexcept;
430b57cec5SDimitry Andric[[noreturn]] void unexpected();
440b57cec5SDimitry Andric
450b57cec5SDimitry Andrictypedef void (*terminate_handler)();
460b57cec5SDimitry Andricterminate_handler set_terminate(terminate_handler  f ) noexcept;
470b57cec5SDimitry Andricterminate_handler get_terminate() noexcept;
480b57cec5SDimitry Andric[[noreturn]] void terminate() noexcept;
490b57cec5SDimitry Andric
500b57cec5SDimitry Andricbool uncaught_exception()  noexcept;
510b57cec5SDimitry Andricint  uncaught_exceptions() noexcept;  // C++17
520b57cec5SDimitry Andric
530b57cec5SDimitry Andrictypedef unspecified exception_ptr;
540b57cec5SDimitry Andric
550b57cec5SDimitry Andricexception_ptr current_exception() noexcept;
560b57cec5SDimitry Andricvoid rethrow_exception [[noreturn]] (exception_ptr p);
570b57cec5SDimitry Andrictemplate<class E> exception_ptr make_exception_ptr(E e) noexcept;
580b57cec5SDimitry Andric
590b57cec5SDimitry Andricclass nested_exception
600b57cec5SDimitry Andric{
610b57cec5SDimitry Andricpublic:
620b57cec5SDimitry Andric    nested_exception() noexcept;
630b57cec5SDimitry Andric    nested_exception(const nested_exception&) noexcept = default;
640b57cec5SDimitry Andric    nested_exception& operator=(const nested_exception&) noexcept = default;
650b57cec5SDimitry Andric    virtual ~nested_exception() = default;
660b57cec5SDimitry Andric
670b57cec5SDimitry Andric    // access functions
680b57cec5SDimitry Andric    [[noreturn]] void rethrow_nested() const;
690b57cec5SDimitry Andric    exception_ptr nested_ptr() const noexcept;
700b57cec5SDimitry Andric};
710b57cec5SDimitry Andric
720b57cec5SDimitry Andrictemplate <class T> [[noreturn]] void throw_with_nested(T&& t);
730b57cec5SDimitry Andrictemplate <class E> void rethrow_if_nested(const E& e);
740b57cec5SDimitry Andric
750b57cec5SDimitry Andric}  // std
760b57cec5SDimitry Andric
770b57cec5SDimitry Andric*/
780b57cec5SDimitry Andric
79fe6060f1SDimitry Andric#include <__config>
80*06c3fb27SDimitry Andric#include <__exception/exception.h>
81*06c3fb27SDimitry Andric#include <__exception/exception_ptr.h>
82*06c3fb27SDimitry Andric#include <__exception/nested_exception.h>
83*06c3fb27SDimitry Andric#include <__exception/operations.h>
84*06c3fb27SDimitry Andric#include <__exception/terminate.h>
850b57cec5SDimitry Andric#include <version>
860b57cec5SDimitry Andric
870b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
880b57cec5SDimitry Andric#  pragma GCC system_header
890b57cec5SDimitry Andric#endif
900b57cec5SDimitry Andric
91bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
92*06c3fb27SDimitry Andric#  include <cstdlib>
93bdd1243dSDimitry Andric#  include <type_traits>
94bdd1243dSDimitry Andric#endif
95bdd1243dSDimitry Andric
960b57cec5SDimitry Andric#endif // _LIBCPP_EXCEPTION
97