31 #ifndef _EXCEPTION_PTR_H
32 #define _EXCEPTION_PTR_H
34 #pragma GCC visibility push(default)
42 #ifdef _GLIBCXX_EH_PTR_RELOPS_COMPAT
43 # define _GLIBCXX_EH_PTR_USED __attribute__((__used__))
45 # define _GLIBCXX_EH_PTR_USED
59 namespace __exception_ptr
64 using __exception_ptr::exception_ptr;
72 template<typename _Ex>
78 namespace __exception_ptr
88 void* _M_exception_object;
92 void _M_addref() _GLIBCXX_USE_NOEXCEPT;
93 void _M_release() _GLIBCXX_USE_NOEXCEPT;
95 void *_M_get()
const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__));
99 template<
typename _Ex>
107 #if __cplusplus >= 201103L
109 : _M_exception_object(
nullptr)
113 : _M_exception_object(__o._M_exception_object)
114 { __o._M_exception_object =
nullptr; }
117 #if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT)
127 #if __cplusplus >= 201103L
131 exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*
this);
141 #ifdef _GLIBCXX_EH_PTR_COMPAT
143 void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT
144 __attribute__ ((__const__));
145 bool operator!()
const _GLIBCXX_USE_NOEXCEPT
146 __attribute__ ((__pure__));
147 operator __safe_bool()
const _GLIBCXX_USE_NOEXCEPT;
150 #if __cplusplus >= 201103L
151 explicit operator bool()
const noexcept
152 {
return _M_exception_object; }
155 #if __cpp_impl_three_way_comparison >= 201907L \
156 && ! defined _GLIBCXX_EH_PTR_RELOPS_COMPAT
160 friend _GLIBCXX_EH_PTR_USED
bool
162 _GLIBCXX_USE_NOEXCEPT
163 {
return __x._M_exception_object == __y._M_exception_object; }
165 friend _GLIBCXX_EH_PTR_USED
bool
167 _GLIBCXX_USE_NOEXCEPT
168 {
return __x._M_exception_object != __y._M_exception_object; }
172 __cxa_exception_type()
const _GLIBCXX_USE_NOEXCEPT
173 __attribute__ ((__pure__));
178 exception_ptr::exception_ptr() _GLIBCXX_NOEXCEPT
179 : _M_exception_object(0)
184 exception_ptr::exception_ptr(
const exception_ptr& __other) _GLIBCXX_NOEXCEPT
185 : _M_exception_object(__other._M_exception_object)
187 if (_M_exception_object)
193 exception_ptr::~exception_ptr() _GLIBCXX_USE_NOEXCEPT
195 if (_M_exception_object)
200 inline exception_ptr&
203 exception_ptr(__other).swap(*
this);
209 exception_ptr::swap(exception_ptr &__other) _GLIBCXX_USE_NOEXCEPT
211 void *__tmp = _M_exception_object;
212 _M_exception_object = __other._M_exception_object;
213 __other._M_exception_object = __tmp;
219 { __lhs.swap(__rhs); }
222 template<
typename _Ex>
224 __dest_thunk(
void* __x)
225 {
static_cast<_Ex*
>(__x)->~_Ex(); }
231 template<
typename _Ex>
235 #if __cpp_exceptions && __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI
236 void* __e = __cxxabiv1::__cxa_allocate_exception(
sizeof(_Ex));
237 (void) __cxxabiv1::__cxa_init_primary_exception(
238 __e, const_cast<std::type_info*>(&
typeid(__ex)),
239 __exception_ptr::__dest_thunk<_Ex>);
242 ::new (__e) _Ex(__ex);
243 return exception_ptr(__e);
247 __cxxabiv1::__cxa_free_exception(__e);
250 #elif __cpp_exceptions
259 #else // no RTTI and no exceptions
260 return exception_ptr();
264 #undef _GLIBCXX_EH_PTR_USED
271 #pragma GCC visibility pop
exception_ptr current_exception() noexcept
exception_ptr make_exception_ptr(_Ex) noexcept
Obtain an exception_ptr pointing to a copy of the supplied object.
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
void rethrow_exception(exception_ptr)
Throw the object pointed to by the exception_ptr.
An opaque pointer to an arbitrary exception.
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.