gcc handling variational patterns is known to be heterogeneous (see, for example, this and this ), but I wonder if the following error is known (I cannot find it in bugzilla) or is it really a mistake. Essentially, gcc (4.8.1) cannot extend the parameter package inside lambda:
#include <vector> #include <algorithm> #include <type_traits> template<typename T, typename F, typename... X> void bar(std::vector<T> const&c, F const&f, X&&... x) { std:for_each(c.begin(),c.end(),[&](const T&t) { f(t,std::forward<X>(x)...); }); }
it causes (even without any instance)
error: parameter packs not expanded with '...': { f(t,std::forward<X>(x)...); }); ^
any idea how to avoid this? (note: is everything ok with icpc 14.0.2 and clang 3.4) Or is gcc correct after all, and clang and icpc are wrong?
edit Note that the problem is lambda, as this also does not compile:
template<typename T, typename F, typename... X> void bar(std::vector<T> const&c, F const&f, X&&... x) { auto func = [&](const T&t){ f(t,std::forward<X>(x)...); }; std:for_each(c.begin(),c.end(),func); }
with an error message in the definition of lambda.
c ++ gcc lambda c ++ 11 variadic-templates
Walter
source share