30 #ifndef _GLIBCXX_NESTED_EXCEPTION_H
31 #define _GLIBCXX_NESTED_EXCEPTION_H 1
33 #pragma GCC visibility push(default)
35 #if __cplusplus < 201103L
39 #include <bits/c++config.h>
41 #if ATOMIC_INT_LOCK_FREE < 2
42 # error This platform does not support exception propagation.
54 class nested_exception
62 nested_exception(
const nested_exception&) =
default;
64 nested_exception& operator=(
const nested_exception&) =
default;
66 virtual ~nested_exception() noexcept;
77 template<
typename _Except>
78 struct _Nested_exception :
public _Except,
public nested_exception
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)
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>
136 throw_with_nested(_Ex __ex)
138 if (__get_nested_exception(__ex))
140 __throw_with_nested(static_cast<_Ex&&>(__ex), &__ex);
144 template<
typename _Ex>
146 rethrow_if_nested(
const _Ex& __ex)
148 if (
const nested_exception* __nested = __get_nested_exception(__ex))
149 __nested->rethrow_nested();
154 rethrow_if_nested(
const nested_exception& __ex)
155 { __ex.rethrow_nested(); }
164 #pragma GCC visibility pop
166 #endif // _GLIBCXX_NESTED_EXCEPTION_H
double __v4df __attribute__((__vector_size__(32)))
Definition: avxintrin.h:32
void rethrow_exception(exception_ptr) __attribute__((__noreturn__))
Throw the object pointed to by the exception_ptr.
exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT