Trouble with std::async syntax

Hey there,
I'm currently trying to use std::async to decouple a web request from the main thread, but I have a problem: I seemingly don't understand the syntax of it, because I can't get this to work:
std::string param {};
std::async(std::launch::async, func, param);
(Don't mind the missing code formatting please, the website doesn't want to)
I always get the error "No type named 'type' in struct xyz". All my attempts of finding a solution on the web always ended in someone suggesting to use std::ref() (Which didn't work for me) or to modify their template and reference stuff, all of which I don't have.
What do you suggest doing? I am out of ideas and stuck at this four hours.
Thanks!

Edit: Oh god dammit. I had to add the optional parameter as well, why did I never notice that....

But one problem still remains: The main thread pauses despite the fact that the async future is put into a variable... What's this now?
Last edited on
But one problem still remains: The main thread pauses despite the fact that the async future is put into a variable... What's this now?

Does the variable go out of scope? In that case it might "pause" until the async thread has completed.

Don't mind the missing code formatting please, the website doesn't want to

It's a forum bug when creating a new thread. You can either put [code] and [/code] around your code manually or edit your post afterwards where the buttons will work.
I tried both ways but got the same delay...

I talked to someone on another platform and they told me that I can't use async like I am trying to as it will pause the main thread nomatter what...

I guess I will close this then. Thanks for trying to help!
Topic archived. No new replies allowed.