c++ - 异常对象的最后一个潜在破坏点

标签 c++ exception language-lawyer destructuring

英语不是我的母语。所以有时阅读 C++ 标准我无法理解写的是什么。 这是一个这样的误解。

在C++ 20 Standard (14.1 Throwing an exception)中写着

  1. ... 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/

相关文章:

c++ - 在 endl 上使用带有重载 << 运算符的 ofstream* 包装类

c++ - 如何创建一个最小的测试用例来展示/EHs 的成本?

c++ - C++ 中的严格别名规则和类型别名

c++ - 计划的目的

c++ - 在 C++ 中将 uint64_t 转换为 void 类型的目的是什么?

Java 空指针异常

java - 异常问题Java

c++ - 读取未初始化的变量

c++ - [dcl.fct.default]/10 中存在明显矛盾

c++ - 根 CERN 导出数据 : export a specific data type