n3526 proposes a slight relaxation of the rules for eliding braces from aggregate initialization in order to make initialization of arrays and class aggregates more uniform.
它将允许以下代码进行编译:
struct S {
int x[2][2];
};
struct A {
S s;
};
// Then the following declarations are all equivalent
A a1 = {{{{1, 2}, {3, 4}}}};
A a2 = {{{1, 2}, {3, 4}}};
A a3 = {{1, 2}, {3, 4}};
A a4 = {1, 2, 3, 4};
然后说:
考虑并拒绝对具有多于一个成员的聚合进行大括号删除,因为这似乎可能会导致难以解析已经格式正确的程序。
有谁知道在使这种语法成为可能方面是否有任何进展,如果没有,为什么会不允许它呢?
Evolution工作组在布里斯托尔会议上审议了该文件,结论是当前的限制是有意为之。我不是本次讨论的一部分,因此对这些细节了解不多。似乎也有人指出,尽管没有给出示例,但即使是上述提案也可能会更改现有的有效代码。据我所知,该提案并未得到执行:
NAD认为,没有建议继续前进。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句