在c ++ 11中使用带有参数包的大括号

时间:2016-03-30 20:59:52

标签: c++ c++11 variadic-templates

我试图确定将模板参数作为参数或单个参数传递的规则。根据指定括号的方式,似乎确定在将模板化类型传递给std :: forward时是否需要....

void test(int)
{

}

template<class... Args>
void foobar(Args&&... args)
{
  test(std::forward<Args...>(args)...);
  test(std::forward<Args>(args)...);
  test(std::forward<Args...>((args)...));
  test(std::forward<Args>((args)...)); // doesn't compile
}

int main()
{
  int x = 5;
  foobar(x);
}  

clang在尝试编译时给出以下内容 错误:参数包未使用“...”展开:    试验(标准::向前((参数)...));

0 个答案:

没有答案