谁能解释 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/