In C ++ there is no such "always execute" operator.
My first tendency is that instead of looking for a new operator, you should overestimate your methods to eliminate any side effects that need to be performed. Perhaps this way you can just use && and be happy.
However, if you really want to complete all the operations in sequence, and then see if they all succeed, Lucian Grigoreβs answer will probably be the best. It clearly defines that these are sequential steps that must always be followed. There is another option, which may or may not be less clear:
// Each method needs to execute in sequence but we use "success" to track overall success. The order of operands to `operator&&` shouldn't be changed. bool success = f1(); success = f2() && success; success = f3() && success; if(success) ...
Mark b
source share