2 //===----------------------------------------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
14 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
15 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
16 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCopy(_Out_ void*,
18 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
19 __ExceptionPtrAssign(_Inout_ void*, _In_ const void*);
20 _CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
21 __ExceptionPtrCompare(_In_ const void*, _In_ const void*);
22 _CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
23 __ExceptionPtrToBool(_In_ const void*);
24 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrSwap(_Inout_ void*,
26 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
27 __ExceptionPtrCurrentException(_Out_ void*);
28 [[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
29 __ExceptionPtrRethrow(_In_ const void*);
30 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
31 __ExceptionPtrCopyException(_Inout_ void*, _In_ const void*, _In_ const void*);
35 exception_ptr::exception_ptr() _NOEXCEPT { __ExceptionPtrCreate(this); }
36 exception_ptr::exception_ptr(nullptr_t) _NOEXCEPT { __ExceptionPtrCreate(this); }
38 exception_ptr::exception_ptr(const exception_ptr& __other) _NOEXCEPT {
39 __ExceptionPtrCopy(this, &__other);
41 exception_ptr& exception_ptr::operator=(const exception_ptr& __other) _NOEXCEPT {
42 __ExceptionPtrAssign(this, &__other);
46 exception_ptr& exception_ptr::operator=(nullptr_t) _NOEXCEPT {
48 __ExceptionPtrAssign(this, &dummy);
52 exception_ptr::~exception_ptr() _NOEXCEPT { __ExceptionPtrDestroy(this); }
54 exception_ptr::operator bool() const _NOEXCEPT {
55 return __ExceptionPtrToBool(this);
58 bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {
59 return __ExceptionPtrCompare(&__x, &__y);
63 void swap(exception_ptr& lhs, exception_ptr& rhs) _NOEXCEPT {
64 __ExceptionPtrSwap(&rhs, &lhs);
67 exception_ptr __copy_exception_ptr(void* __except, const void* __ptr) {
68 exception_ptr __ret = nullptr;
70 __ExceptionPtrCopyException(&__ret, __except, __ptr);
74 exception_ptr current_exception() _NOEXCEPT {
76 __ExceptionPtrCurrentException(&__ret);
81 void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); }
83 nested_exception::nested_exception() _NOEXCEPT : __ptr_(current_exception()) {}
85 nested_exception::~nested_exception() _NOEXCEPT {}
88 void nested_exception::rethrow_nested() const {
89 if (__ptr_ == nullptr)
91 rethrow_exception(__ptr_);