【发布时间】:2015-10-20 22:06:43
【问题描述】:
来自 C++11 标准,§7.3.3[namespace.udecl]/1:
using-declaration 将名称引入到 using-declaration 出现的声明区域中。
使用声明:
using typenameoptnested-name-specifier unqualified-id;using ::unqualified- id;在 using-declaration 中指定的成员名称在 using-declaration 出现的声明区域中声明。
在使用声明发生的声明区域中声明的名称是什么意思?
这是否意味着将该名称引入到使用声明发生的声明区域中?
声明名称和声明名称所表示的实体之间也有区别吗?
例子:
namespace N { static int i = 1; } /* Declares an entity denoted by
the name i in the declarative region of the namespace N.
Introduces the name into the declarative region of the namespace N.
Declares the name i in the declarative region of the namespace N? */
using N::i; /* Declares the name i in the declarative region of the
global namespace. Also introduces that name into the declarative
region of the global namespace? Also declares the entity that the
name i denotes? */
【问题讨论】:
-
现在我正在回答你关于这个话题的第三个问题,我想我终于明白了!
-
@Barry 我正在耐心等待 Supremum 对标准的探索以触及第 14 条。啊,那将是一连串的问题和错误报告! :-)
-
@Supremum 我希望你没有以错误的方式接受上面的评论 - 这是友好的玩笑。你提出了有趣的问题,其中一些根本不明显。继续问!
-
到目前为止:clang 中的 10 个未拒绝的错误(3 个已修复)和 gcc 中的 13 个未拒绝的错误(8 个已确认,0 个已修复)。到目前为止,我主要看的是第 3 章和第 7 章:P
-
感谢巴里的帮助。我现在不那么困惑了。然而,我意识到 c++ 标准的术语不能 100% 精确,我不应该把所有的东西都看得太字面意思。理解使用的术语很好,但它们的精确度有限制。我可能应该更多地专注于制作我自己的 c++ 标准心智模型。这通常是我学习事物的方式,用我自己的话来解释。
标签: c++ entity declaration language-lawyer using-declaration