If I have a exception stored inside std::exception_ptr
. I rethrow the exception using std::rethrow_exception
, access it using catch(MyException&)
and then I modify the value.
If I throw the same exception again, should I observe the modification I made?
The following code demonstrate my idea:
#include <exception>
#include <iostream>
struct MyException {
int value;
};
int main() {
std::exception_ptr a = std::make_exception_ptr(MyException());
try {
std::rethrow_exception(a);
} catch(MyException& b) {
std::cout << b.value << std::endl;
b.value = 3;
}
try {
std::rethrow_exception(a);
} catch(MyException& b) {
std::cout << b.value << std::endl;
}
}
Aucun commentaire:
Enregistrer un commentaire