I need to do conditional behavior.
std::future<int> f = pointer ? std::async(&Class::method, ptr) : 0;
// ... Some code
x = f.get();
So I would like to assign to x result async result of ptr->method() call or 0 if ptr is a nullptr.
Is the code above ok? Can I do anything like that (assign 'int' to 'std::futture'? Or maybe there is a better solution?
Aucun commentaire:
Enregistrer un commentaire