gpt4 book ai didi

c++ - N4140 中 [basic.link]/8 中要点的目的是什么?他们似乎没有带来任何新的东西

转载 作者:太空狗 更新时间:2023-10-29 23:00:35 24 4
gpt4 key购买 nike

N4140 中的[basic.link]/8 包含以下语句:

A type without linkage shall not be used as the type of a variable or function with external linkage unless
(8.7) — the entity has C language linkage (7.5), or
(8.8) — the entity is declared within an unnamed namespace (7.3.1), or
(8.9) — the entity is not odr-used (3.2) or is defined in the same translation unit.

显然满足 (8.8) 的条件是不可能的,因为在未命名命名空间中声明的实体不能同时具有外部链接。

然后我决定找一个带有外部链接的函数返回一个没有链接的类型的例子,即返回一个局部类的对象,不管函数是否在与类型相同的 TU。恐怕满足(8.9)的选项集也可能是空的。如果是这样的话,我想听听对此的一些确认。

关于(8.7)我不知道该说什么,但在我看来,这个要点也不会给问题增加任何新内容。

最佳答案

所以看起来 8.8 是一个缺陷,它被 defect report 2058: More errors from internal-linkage namespaces 覆盖了:

Issue 1603 dealt with omissions in the application of the change to give unnamed namespaces internal linkage, but its resolution overlooked a couple of items.

[...]

Also, 3.5 [basic.link] paragraph 8 says,

A type without linkage shall not be used as the type of a variable or function with external linkage unless

...

the entity is declared within an unnamed namespace (7.3.1 [namespace.def]), or

...

这个项目符号不会出现,因为在未命名的命名空间中声明的函数或变量不能有外部链接。

8.9defect report 757 添加其中包括一个基本原理。

关于c++ - N4140 中 [basic.link]/8 中要点的目的是什么?他们似乎没有带来任何新的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33420347/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com