balki
balki

Reputation: 27674

How to use async with lambdas which does not return anything?

I have a simple lambda called inside async. But it gives a system_error.

#include<future>
#include<iostream>

int main()
{
    auto a = std::async([]()
    {
        std::cout << 42 << std::endl;
    });
    a.get();
    return 0;
}

http://ideone.com/GIyGI

Compiler: C++0x (gcc-4.5.1)

Any ideas?

Upvotes: 1

Views: 205

Answers (1)

wjl
wjl

Reputation: 7735

Most likely, you need to compile with the -pthread option.

Upvotes: 2

Related Questions