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?

1
  • template<class CT> auto run_col(Run<CT>const&run){return [&](auto&&... params){ return column(run,std::forward<decltype(params)>(params)...);};} instantiated with auto col = run_col(run); appears to work. Also auto col = [&run](auto&&... p){return column(run,std::forward<decltype(p)>(p)...);}; appears to work. Commented Jun 20, 2016 at 20:00

1 Answer 1

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)...);
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.