Parameter packages are not expanded with "..." - another variational pattern error with gcc?

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.

+7
c ++ gcc lambda c ++ 11 variadic-templates
source share
1 answer

Given that the code is compiled using both clang version 3.5 (trunk 202594) and, more importantly, with gcc version 4.9.0 20140302 (experimental) (GCC), both with -Wall , I would say that this was a problem with earlier versions of gcc.

I am looking for a gcc archive at http://gcc.gnu.org/bugzilla/ to confirm this.

+8
source share

All Articles