Std::rethrow_Exception mit std::current_Exception

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Std::rethrow_Exception mit std::current_Exception

by Guest » 05 Jan 2025, 07:39

Ich fummele nur ohne weiteren Grund mit Ausnahmen herum. In C++20 ist mir ein Verhalten rund um die Funktion std::rethrow_Exception aufgefallen, wenn sie mit verschachtelten Ausnahmen und std::current_Exception verwendet wird.
Betrachten Sie dieses Beispiel :

Code: Select all

#include 
#include 

using namespace std;

int main()
{
struct B {
B(int ii): i(ii) { }
virtual ~B() { }
int i;
};

try {
try {
throw B(1);
}
catch (const B &b) {
std::throw_with_nested(B(2));
}
}
catch (const B &b) {
cout

Top