std::pomise / std::future, uninteligible linker errors.

I've been trying to figure out how to get a return value back from a thread, and found all kinds of info on promises, futures, packaged_somethings, async, .... it's all confusing to me.

Here's one of my failed attempts at promses/futures

http://pastebin.com/3r6RNRQQ

Everything I've found - all the examples, all the explanations - make absolutely no sense to me. Could someone perhaps talk to me like a toddler and use sock puppets to explain this?

Last edited on
The code posted is not the code compiled ("#include fuiture>" won't parse).

The message you posted is from the compiler, not from the linker, and it's telling you that the first argument to the thread constructor, &func, cannot be called with the second argument to the thread constructor, val, as a parameter. &func is a pointer to function that takes two parameters, but you're trying to call it with one.

You can make your program work by changing just one line:

1
2
// std::thread t(&func, val );
std::thread t(&func, std::move(p), val );
Topic archived. No new replies allowed.