cpp: catch exception with ellipsis and see the information

亡梦爱人 提交于 2019-11-29 11:31:14

Sorry, you can't do that. You can only access the exception object in a catch block for a specific exception type.

From C++11 and onwards, you can use std::current_exception &c:

std::exception_ptr p;
try {

} catch(...) {
    p = std::current_exception();
}

You can then "inspect" p by taking casts &c.

In earlier standards there is no portable way of inspecting the exception at a catch(...) site.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!