小编Ale*_*exT的帖子

与std :: current_exception关联的数据的生命周期

请考虑以下代码:

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什么?谢谢!

c++ exception c++11

4
推荐指数
1
解决办法
509
查看次数

标签 统计

c++ ×1

c++11 ×1

exception ×1