我想使用别名std::initializer_list代替自己:
#include<initializer_list>
template< typename T >
using InitializerList = std::initializer_list<T>;
// note: candidate template ignored: couldn't infer template argument 'T'
template< typename T >
void f(InitializerList<T> list) {
}
int main() {
// error: no matching function for call to 'f'
f({1, 2, 3, 4, 5});
}
Run Code Online (Sandbox Code Playgroud)
使用gcc&cl,该代码很好.但是,使用clang我收到错误:
<source>:11:3: error: no matching function for call to 'f'
f({1, 2, 3, 4, 5});
^
<source>:7:6: note: candidate template ignored: couldn't infer template argument 'T'
void f(InitializerList<T> list) {
^ …Run Code Online (Sandbox Code Playgroud)