lundi 15 février 2021

C++ std::future

Considering the following, would it be possible to recurse into the function? I don’t think std::move would work, as on unwinding the variable would be gone, how would you approach something like this?

auto TestFunc(std::future<bool> promisedExit
        , int max
        , const char* pszTesting)
{
  if (promisedExit.get()) { // The calling thread will set this to cause this thread to exit.
     return false;
  }
  ...
  ...
  ...
  if (max != 10) {
     TestFunc(std::move(promisedExit), max++, pszTesting);
  }
  ...
  ...
  ...
}

Aucun commentaire:

Enregistrer un commentaire