相关,但(imho)不同:
Nested template argument deduction for class templates not working
下面的C++ 17代码从GCC 8中被拒绝,但是CLAN编译它没有任何问题。GCC的错误消息作为注释包含在有问题的行之前。
这里哪个编译器是正确的?
https://godbolt.org/z/WG6f7G
template<class T>
struct Foo {
Foo(T) {}
};
template<class T>
struct Bar {
Bar(T) {};
};
void works() {
Bar bar{1};// {}
Foo foo(bar);// ()
}
void works_too() {
Foo foo{Bar{1}};// {{}}
}
void error_in_gcc() {
// error: 'auto' parameter not permitted in this context
Foo foo(Bar{1});// ({})
}
void but_this_works() {
Foo(Bar{1});// ({})
}