What can I do with std :: exception_ptr, except for its repeated

I have an object of type std::exception_ptr and I want to call it what() , but there seems to be no way to do this (as explained in this answer: How to make what () call on std :: exception_ptr ).

After searching the Internet, it seems that I can do nothing with it except re-throwing it and looking for it in std::exception& to do this.

This is a little strange for me, but I want to check: what can others do with std::exception_ptr and then re-throw it to get the wait detail?

Are there any changes in C ++ 14 or other versions of C ++

+5
source share
1 answer

Unfortunately not. The standard guarantees only for std::exception_ptr :

18.8.5 Distributing Exceptions

1 The type exception_ptr can be used to refer to an exception object.

2 exception_ptr must satisfy the requirements of NullablePointer (17.6.3.3).

3 Two non-empty values ​​of type exception_ptr are equivalent and are compared equal if and only if they refer to the same exception.

4 The default constructor exception_ptr creates a null type value.

5 exception_ptr cannot be implicitly convertible to any type of arithmetic, enumeration, or pointer.

7 To determine whether there is a race of data, operations on exception_ptr objects must access and change only the exception_ptr objects themselves, and not the exceptions to which they relate.

Also noted here

Performing any other operation on an object (for example, dereferencing it), if supported by the library implementation at all, causes undefined behavior.

+2
source

Source: https://habr.com/ru/post/1261343/


All Articles