31 #ifndef _EXCEPTION_PTR_H 32 #define _EXCEPTION_PTR_H 40 #if __cplusplus >= 201103L 44 #ifdef _GLIBCXX_EH_PTR_RELOPS_COMPAT 45 # define _GLIBCXX_EH_PTR_USED __attribute__((__used__)) 47 # define _GLIBCXX_EH_PTR_USED 52 namespace std _GLIBCXX_VISIBILITY(default)
61 namespace __exception_ptr
66 using __exception_ptr::exception_ptr;
77 template<typename _Ex>
83 namespace __exception_ptr
99 void* _M_exception_object;
103 void _M_addref() _GLIBCXX_USE_NOEXCEPT;
104 void _M_release() _GLIBCXX_USE_NOEXCEPT;
106 void *_M_get()
const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__));
110 template<
typename _Ex>
118 #if __cplusplus >= 201103L 120 : _M_exception_object(
nullptr)
124 : _M_exception_object(__o._M_exception_object)
125 { __o._M_exception_object =
nullptr; }
128 #if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT) 138 #if __cplusplus >= 201103L 142 exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*
this);
152 #ifdef _GLIBCXX_EH_PTR_COMPAT 154 void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT;
155 bool operator!()
const _GLIBCXX_USE_NOEXCEPT
156 __attribute__ ((__pure__));
157 operator __safe_bool()
const _GLIBCXX_USE_NOEXCEPT;
160 #if __cplusplus >= 201103L 161 explicit operator bool()
const noexcept
162 {
return _M_exception_object; }
165 #if __cpp_impl_three_way_comparison >= 201907L \ 166 && ! defined _GLIBCXX_EH_PTR_RELOPS_COMPAT 170 friend _GLIBCXX_EH_PTR_USED
bool 172 _GLIBCXX_USE_NOEXCEPT
173 {
return __x._M_exception_object == __y._M_exception_object; }
175 friend _GLIBCXX_EH_PTR_USED
bool 177 _GLIBCXX_USE_NOEXCEPT
178 {
return __x._M_exception_object != __y._M_exception_object; }
182 __cxa_exception_type()
const _GLIBCXX_USE_NOEXCEPT
183 __attribute__ ((__pure__));
188 exception_ptr::exception_ptr() _GLIBCXX_USE_NOEXCEPT
189 : _M_exception_object(0)
195 _GLIBCXX_USE_NOEXCEPT
196 : _M_exception_object(__other._M_exception_object)
198 if (_M_exception_object)
204 exception_ptr::~exception_ptr() _GLIBCXX_USE_NOEXCEPT
206 if (_M_exception_object)
211 inline exception_ptr&
212 exception_ptr::operator=(
const exception_ptr& __other) _GLIBCXX_USE_NOEXCEPT
214 exception_ptr(__other).swap(*
this);
220 exception_ptr::swap(exception_ptr &__other) _GLIBCXX_USE_NOEXCEPT
222 void *__tmp = _M_exception_object;
223 _M_exception_object = __other._M_exception_object;
224 __other._M_exception_object = __tmp;
230 { __lhs.swap(__rhs); }
233 template<
typename _Ex>
234 _GLIBCXX_CDTOR_CALLABI
236 __dest_thunk(
void* __x)
237 {
static_cast<_Ex*
>(__x)->~_Ex(); }
242 using __exception_ptr::swap;
245 #if (__cplusplus >= 201103L && __cpp_rtti) || __cpp_exceptions 246 template<
typename _Ex>
250 #if __cplusplus >= 201103L && __cpp_rtti 251 using _Ex2 =
typename decay<_Ex>::type;
252 void* __e = __cxxabiv1::__cxa_allocate_exception(
sizeof(_Ex));
253 (void) __cxxabiv1::__cxa_init_primary_exception(
254 __e, const_cast<std::type_info*>(&
typeid(_Ex)),
255 __exception_ptr::__dest_thunk<_Ex2>);
258 ::new (__e) _Ex2(__ex);
263 __cxxabiv1::__cxa_free_exception(__e);
277 #else // no RTTI and no exceptions 280 template<
typename _Ex>
281 __attribute__ ((__always_inline__))
284 {
return exception_ptr(); }
287 #undef _GLIBCXX_EH_PTR_USED ISO C++ entities toplevel namespace is std.
exception_ptr make_exception_ptr(_Ex) noexcept
Obtain an exception_ptr pointing to a copy of the supplied object.
An opaque pointer to an arbitrary exception.
exception_ptr current_exception() noexcept
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
void rethrow_exception(exception_ptr)
Throw the object pointed to by the exception_ptr.