请考虑以下代码:
std::exception_ptr eptr{ std::current_exception() };
const char* msg = 0;
try {
if (eptr != std::exception_ptr{}) {
std::rethrow_exception(eptr);
}
} catch(const std::exception& ex) {
msg = ex.what();
}
Run Code Online (Sandbox Code Playgroud)
我可以msg在外面使用catch吗?换句话说,ex引用相同的异常实例是eptr什么?谢谢!