jeudi 22 octobre 2020

Is there a more C++ elegant implementation to complete the function jump?

In my daily work, I usually write my code like this:

int ret = 0;
ret = func1();
if(ret != 0) {
  return ret;
}
ret = func2();
if(ret != 0) {
  return ret;
}

But this means I need to complete a lot of "if(ret!=0){return ret;}",Is there a more C++ elegant implementation to complete the function jump? By the way, we are not allowed to use exception.

Aucun commentaire:

Enregistrer un commentaire