c++ - How to capture variable number of arguments in lambda function -


i tried following code doesn't compile.

template <class t, class... a> void tpool::enqueue(t&& func, a&&... args) {     std::function<void()> task([func, args] () {         //...     }); } 

just use ellipses. per paragraph 5.1.2/23 of c++11 standard:

a capture followed ellipsis pack expansion (14.5.3). [ example:

template<class... args> void f(args... args) {     auto lm = [&, args...] { return g(args...); };     lm(); } 

end example ]

note: interestingly enough, gcc refusing compile (see live example):

template <class t, class... a> void foo(t&& func, a&&... args) {     std::function<void()> task([func, args...] () {         //...     }); } 

but considering above example standard, compiler issue.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -