30 #ifndef _GLIBCXX_NESTED_EXCEPTION_H
31 #define _GLIBCXX_NESTED_EXCEPTION_H 1
33 #pragma GCC visibility push(default)
35 #if __cplusplus < 201103L
42 #if ATOMIC_INT_LOCK_FREE < 2
43 # error This platform does not support exception propagation.
71 rethrow_nested()
const
79 nested_ptr()
const noexcept
83 template<
typename _Except>
86 explicit _Nested_exception(
const _Except& __ex)
90 explicit _Nested_exception(_Except&& __ex)
91 : _Except(static_cast<_Except&&>(__ex))
98 template<
typename _Tp>
100 __throw_with_nested_impl(_Tp&& __t,
true_type)
102 using _Up =
typename remove_reference<_Tp>::type;
103 throw _Nested_exception<_Up>{std::forward<_Tp>(__t)};
106 template<
typename _Tp>
108 __throw_with_nested_impl(_Tp&& __t,
false_type)
109 {
throw std::forward<_Tp>(__t); }
113 template<
typename _Tp>
118 using _Up =
typename decay<_Tp>::type;
119 using _CopyConstructible
120 = __and_<is_copy_constructible<_Up>, is_move_constructible<_Up>>;
121 static_assert(_CopyConstructible::value,
122 "throw_with_nested argument must be CopyConstructible");
123 using __nest = __and_<is_class<_Up>,
__bool_constant<!__is_final(_Up)>,
124 __not_<is_base_of<nested_exception, _Up>>>;
125 std::__throw_with_nested_impl(std::forward<_Tp>(__t), __nest{});
129 template<
typename _Tp>
130 using __rethrow_if_nested_cond =
typename enable_if<
131 __and_<is_polymorphic<_Tp>,
132 __or_<__not_<is_base_of<nested_exception, _Tp>>,
133 is_convertible<_Tp*, nested_exception*>>>::value
137 template<
typename _Ex>
138 inline __rethrow_if_nested_cond<_Ex>
139 __rethrow_if_nested_impl(
const _Ex* __ptr)
141 if (
auto __ne_ptr = dynamic_cast<const nested_exception*>(__ptr))
142 __ne_ptr->rethrow_nested();
147 __rethrow_if_nested_impl(
const void*)
151 template<
typename _Ex>
163 #pragma GCC visibility pop
165 #endif // _GLIBCXX_NESTED_EXCEPTION_H