- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
根据来自 N4140 的 [basic.lookup.unqual]/8下面的片段应该编译。但它不在 clang 中, gcc 和 vs2013。
struct C {
void f(I) {}
using I = int;
};
[basic.lookup.unqual]/8(重点是我的):
For the members of a class
X
, a name used in a member function body, in a default argument, in an exception-specification, in the brace-or-equal-initializer of a non-static data member (9.2), or in the definition of a class member outside of the definition ofX
, following the member’s declarator-id31, shall be declared in one of the following ways:
- before its use in the block in which it is used or in an enclosing block (6.3), or
- shall be a member of class
X
or be a member of a base class ofX
(10.2), or- ...
31) That is, an unqualified name that occurs, for instance, in a type in the parameter-declaration-clause or in the exceptions-pecification.
最佳答案
您使用它的方式不符合[basic.lookup.unqual]/8 中的任何条件,它未被使用:
而且它也不属于这种情况:
definition of a class member outside of the definition of X
以下示例显示了一些确实遵循这些规则的情况:
struct C {
int y = I() ; // brace-or-equal-initializer of non-static data member
void f(int x = I()) // default argument
noexcept(sizeof(I)<4) // exception-specification
{
I i = x ; // member function body
}
using I = int;
};
关于c++ - 根据我对 §3.4.1/8 的解释,这段代码应该可以编译。我错过了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31457627/
我无法在附加行中显示“真”、“假”、"is"和“否”按钮。 我在这里有一个应用程序:Application 请按照以下步骤使用应用程序: 1。当你打开应用程序时,你会看到一个绿色的加号按钮,点击 在此
我是一名优秀的程序员,十分优秀!