c++ - 下面最后一句话(粗体)与复制抛出的异常有什么关系?

标签 c++ exception

这是 Stroustup 的书的摘录,第 3 版,第 362 页:

In principle, an exception is copied when it is thrown, so the handler gets hold of a copy of the original exception. In fact, an exception may be copied several times before it is caught. Consequently, we cannot throw an exception that cannot be copied. The implementation may apply a wide variety of strategies for storing and transmitting exceptions. It is guaranteed, however, that there is sufficient memory to allow new to throw the standard outofmemory exception, bad_alloc.

最佳答案

这意味着如果你用完内存并且调用 new() 抛出一个 std::bad_alloc,将保留一些内存来创建,并在没有的情况下制作正确数量的 std::bad_alloc 对象作为抛出异常的过程抛出另一个 std::bad_alloc。

关于c++ - 下面最后一句话(粗体)与复制抛出的异常有什么关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8943550/

相关文章:

javascript - Mousedown jquery 除了与否

api - 如何将错误异常存储在变量中并作为json返回

c# - Windows 手机 : Application Exits after handling Exception from DialogForm

c++ - map 的开始迭代器不起作用 C++

c++ - 为什么命令不执行?

java - ExceptionMapper 的 Jersey/Jackson 异常问题

c# - 由于内存不足异常,函数评估被禁用

c++ - Stringstream 到 vector<int>

C++ 11查找类型是否具有成员函数或支持运算符的方法?

c++ - std::bind 类成员函数