This code works fine in 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>(); }
However, in GCC 4.9, the following error occurs instead:
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; })...);
So, does the compiler have an error, Clang or GCC? Clan behavior is of the utmost importance to me.
lambda c ++ 11 variadic-templates
Emil Eriksson
source share