c++ - 谁能解释一下当前C++0x标准草案的这一段?

标签 c++ c++11 standards one-definition-rule

谁能解释 ISO N3242 §3.2 第 2 点中的这个陈述

A non-placement allocation or deallocation function for a class is odr-used by the definition of a constructor of that class. A non-placement deallocation function for a class is odr-usedby the definition of the destructor of that class, or by being selected by the lookup at the point of definitionof a virtual destructor (12.4).26 A copy-assignment function for a class is odr-used by an implicitly-defined copy-assignment function for another class as specified in 12.8. A move-assignment function for a class is odr-used by an implicitly-defined move-assignment function for another class as specified in 12.8.

ISO 标准 2003 说:

A copy-assignment function for a class is used by an implicitly-defined copy-assignment function for another class as specified in 12.8.

这些陈述的实际区别是什么?

有人用示例/程序来解释上面添加的点吗?

我知道移动构造函数/移动赋值函数 --> 添加了新功能。

任何人都可以借助示例/程序来解释这一点吗?

请......

请............回答

最佳答案

可以找到此添加的基本原理和示例 here .简而言之,它明确了何时需要定义类的分配/释放函数。

(C++03) 单一定义规则要求程序中使用 的每个变量或函数,对于“使用”的非常具体的定义,必须只有一个定义。 因此,对何时(取消)分配函数被视为“已使用”的描述也规定了何时需要定义。

为避免混淆“使用”一词的一般含义和 ODR 中定义的“使用”的含义,只要有第二种含义,“使用”一词就会替换为“odr-use”。

关于c++ - 谁能解释一下当前C++0x标准草案的这一段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5620008/

相关文章:

c++ - const_cast 在常量表达式中有效吗? (C++14, C++17)

C++增强猫

c++11 - 如何使用 Eigen 的逐元素整数幂

html - 在 HTML 中使用过时的标签是错误的吗?

c++ - 为什么 `ranges::view::for_each` 要求仿函数必须返回 `InputRange` 概念的模型?

c++ - 双重检查锁定模式

c++ - 在cpp中格式化

c++ - 如何编写以可变参数作为模板参数的成员函数

perl - 一个 CPAN 模块来解析 google 风格的搜索查询术语?

c++ - 如果我忽略具有 shared_ptr 返回类型的函数的返回值怎么办