There are numerous ways of handling this that are significantly better, for example using an std::optional yields this code:
do_something().and_then(process);
Or structured bindings: auto [error_code, result] = do_something();
if(error_code == 0) {
process(result);
}