0

For ridiculous reasons, I need the following generic variadic lambda function. GCC 5.3.0 on MINGW-w64 is rejecting it. column is a function template.

auto col = [&run](auto&&... params){return column(run,params);}; //error

Diagnostics:

..\src\RunOutputData.cpp: In lambda function:
..\src\RunOutputData.cpp:94:64: error: parameter packs not expanded with '...':
  auto col = [&run](auto&&... params){return column(run,params);};
                                                                ^
..\src\RunOutputData.cpp:94:64: note:         'params'

Is GCC wrong?

Community
  • 1
  • 1
  • `template auto run_col(Runconst&run){return [&](auto&&... params){ return column(run,std::forward(params)...);};}` instantiated with `auto col = run_col(run);` appears to work. Also `auto col = [&run](auto&&... p){return column(run,std::forward(p)...);};` appears to work. –  Jun 20 '16 at 20:00

1 Answers1

1

In col lambda you are using a parameter pack but you are not expanding it.

One of solutions to your problem is expanding it inside the parenthesis with parameters to column (granted it is defined and will accept the parameters that you pass to it) so that column will be called with all the parameters contained in params...

auto col = [&run](auto&&... params)
{
    return column(run, params...);
};

or with perfect forwarding as you've done it:

auto col = [&run](auto&&... params)
{
    return column(run, std::forward<decltype(params)>(params)...);
};
Patryk
  • 22,602
  • 44
  • 128
  • 244