英语不是我的母语。所以有时阅读 C++ 标准我无法理解写的是什么。 这是一个这样的误解。
在C++ 20 Standard (14.1 Throwing an exception)中写着
- ... The points of potential destruction for the exception object are:
(4.1) — when an active handler for the exception exits by any means other than rethrowing, immediately after the destruction of the object (if any) declared in the exception-declaration in the handler;
(4.2) — when an object of type std::exception_ptr (17.9.6) that refers to the exception object is destroyed, before the destructor of std::exception_ptr returns.
然后
Among all points of potential destruction for the exception object, there is an unspecified last one where the exception object is destroyed. All other points happen before that last one.
什么是“最后的毁灭点”?它在标准中的含义是什么?
似乎已经列出了异常对象的所有潜在破坏点。
最佳答案
这只是一种滑稽的密集说法:
The exception object is allowed to die at these points: [...].
One of these points will be the last one (duh), and at that point the exception will actually die.
The implementation is free to order these points as it wants, as long as it can determine which one is last to kill the exception at the right time.
换句话说,它做正确的事™。
关于c++ - 异常对象的最后一个潜在破坏点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57184495/