【发布时间】:2015-03-31 17:38:22
【问题描述】:
此代码在 Clang 3.5 中运行良好:
#include <iostream>
#include <string>
void callFuncs() {}
template<typename Func, typename ...Funcs>
void callFuncs(const Func &func, const Funcs &...funcs)
{
func();
callFuncs(funcs...);
}
template<typename ...Types>
void callPrintFuncs()
{
callFuncs(([] { std::cout << Types() << std::endl; })...);
}
int main()
{
callPrintFuncs<int, float, double, std::string>();
}
但是,在 GCC 4.9 中,我收到以下错误:
test.cpp: In lambda function:
test.cpp:16:54: error: parameter packs not expanded with '...':
callFuncs(([] { std::cout << Types() << std::endl; })...);
^
test.cpp:16:54: note: 'Types'
test.cpp: In function 'void callPrintFuncs()':
test.cpp:16:58: error: expansion pattern '<lambda>' contains no argument packs
callFuncs(([] { std::cout << Types() << std::endl; })...);
那么,哪个编译器有错误,Clang 还是 GCC?至少 Clang 行为对我来说是最有意义的。
【问题讨论】:
-
奇怪的是这还没有解决。我想再次确认,但是在尝试创建帐户时,它说帐户创建受到限制... GCC 死了吗?
-
Gcc 和许多人一样,是垃圾邮件发送者的受害者。您所在的页面提供了有关如何创建帐户的说明(发送电子邮件至监督者@...)。
-
乍一看,代码假定语句末尾的未扩展参数包是错误的。
标签: c++11 lambda variadic-templates