函数定义:
void foo(const char*) {}
-
foo(char[16]{}); //houston, there is a problem!
-
foo(type_alias<char[16]>{}); //compile happily
type_alias
很简单:
template<typename T>
using type_alias = T;
live demon
如评论所述,
case 1
无法编译while
case 2
罐头。
我知道
alias declarations
具有
using
不是文本替换(如
#define
)它是这个类型的同义词。
但我还是不知道该如何解释这种情况。然后我给
海湾合作委员会
一
try
:
prog.cc: In function 'int main()':
prog.cc:11:7: error: expected primary-expression before 'char'
foo(char[16]{});
^~~~
prog.cc:12:7: error: taking address of temporary array
foo(type_alias<char[16]>{});
^~~~~~~~~~~~~~~~~~~~~~
啊,
海湾合作委员会
却给了我一个错误!然后我用两个编译器的不同版本编译它:
prog.cc:11:11:错误:对于函数样式转换或类型构造,应为“(”
foo(char[16]{});
~~~~^
BTW,用于
铿锵声
,我还测试了
pedantic-errors
,但没有改变。
问题:
-
对于
案例2
:
铿锵声
,
海湾合作委员会
,谁符合标准?有什么标准(语言律师)规范吗?
-
对于
案例1
:谁的错误消息更正确(IOW,符合标准)?
更新
作为VTT的评论,
案例1
,应该是
foo(const char[16]{});
. 为这个错误道歉。
但是
铿锵声
可以编译
foo(type_alias<char[16]>{});
. 好像是虫子?