小编Bro*_*ang的帖子

在clang中别名std :: initializer_list

我想使用别名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)

c++ clang c++11 clang++

8
推荐指数
1
解决办法
158
查看次数

标签 统计

c++ ×1

c++11 ×1

clang ×1

clang++ ×1