30 #ifndef _GLIBCXX_NESTED_EXCEPTION_H
31 #define _GLIBCXX_NESTED_EXCEPTION_H 1
33 #pragma GCC visibility push(default)
35 #if __cplusplus < 201103L
41 #if ATOMIC_INT_LOCK_FREE < 2
42 # error This platform does not support exception propagation.
69 rethrow_nested()
const __attribute__ ((__noreturn__))
77 template<
typename _Except>
80 explicit _Nested_exception(_Except&& __ex)
81 : _Except(static_cast<_Except&&>(__ex))
85 template<
typename _Ex>
86 struct __get_nested_helper
88 static const nested_exception*
89 _S_get(
const _Ex& __ex)
90 {
return dynamic_cast<const nested_exception*
>(&__ex); }
93 template<
typename _Ex>
94 struct __get_nested_helper<_Ex*>
96 static const nested_exception*
97 _S_get(
const _Ex* __ex)
98 {
return dynamic_cast<const nested_exception*
>(__ex); }
101 template<
typename _Ex>
102 inline const nested_exception*
103 __get_nested_exception(
const _Ex& __ex)
104 {
return __get_nested_helper<_Ex>::_S_get(__ex); }
106 template<
typename _Ex>
108 __throw_with_nested(_Ex&&,
const nested_exception* = 0)
109 __attribute__ ((__noreturn__));
111 template<typename _Ex>
113 __throw_with_nested(_Ex&&, ...) __attribute__ ((__noreturn__));
118 template<typename _Ex>
120 __throw_with_nested(_Ex&& __ex, const nested_exception*)
123 template<
typename _Ex>
125 __throw_with_nested(_Ex&& __ex, ...)
126 {
throw _Nested_exception<_Ex>(
static_cast<_Ex&&
>(__ex)); }
128 template<
typename _Ex>
134 template<
typename _Ex>
138 if (__get_nested_exception(__ex))
140 __throw_with_nested(static_cast<_Ex&&>(__ex), &__ex);
144 template<
typename _Ex>
149 __nested->rethrow_nested();
155 { __ex.rethrow_nested(); }
164 #pragma GCC visibility pop
166 #endif // _GLIBCXX_NESTED_EXCEPTION_H
exception_ptr current_exception() noexcept
Exception class with exception_ptr data member.
void throw_with_nested(_Ex __ex) __attribute__((__noreturn__))
If __ex is derived from nested_exception, __ex. Else, an implementation-defined object derived from b...
void rethrow_if_nested(const _Ex &__ex)
If __ex is derived from nested_exception, __ex.rethrow_nested().
void rethrow_exception(exception_ptr) __attribute__((__noreturn__))
Throw the object pointed to by the exception_ptr.