I did some testing with std::packaged_task and came accross this problem.
std::packaged_task<int(void)> task([]() -> int { return 1; });
task();
compiles and calling task()
really does the lambda.
However this one does not compile:
std::pair<int, std::packaged_task<int(void)>> pair(15, []() -> int { return 15; });
pair.second();
because
error C2664: 'std::pair<int,std::packaged_task<int (void)>>::pair(const std::pair<int,std::packaged_task<int (void)>> &)': cannot convert argument 2 from 'main::<lambda_abbe6cccb9110894d95e872872ec1296>' to 'const std::packaged_task<int (void)> &'
Aucun commentaire:
Enregistrer un commentaire