08-16-2016, 10:44 PM
(08-01-2016, 08:41 AM)tigerw Wrote: Could anyone help me get this snippet to compile?
1234567891011121314151617181920212223#include <memory>
#include <vector>
#include <future>
using
namespace
std;
vector<packaged_task<
void
()>> veccy;
template
<
typename
T>
void
queue(T Task)
{
veccy.emplace_back(move(Task));
}
int
main()
{
unique_ptr<
int
> un;
queue(
[un = move(un)]
{
}
);
return
0;
}
It tells me that:
Code:Error C2280 'main::<lambda_2dcc5207d1d056d2ef4fc2991b66fdec>::<lambda_2dcc5207d1d056d2ef4fc2991b66fdec>(const main::<lambda_2dcc5207d1d056d2ef4fc2991b66fdec> &)': attempting to reference a deleted function ConsoleApplication1 c:\program files (x86)\microsoft visual studio 14.0\vc\include\xutility 288
Well, it seems that it's a Visual Studio compiler issue (duly reported and fixed). In the meantime, a workaround is to use a class which moves itself when copied.