Add an ordinary early return to process: if value is negative, print Invalid value and return before
reaching the Processing: line. There’s nothing unusual about the if itself – the point of this exercise is
what happens around it.
Look at the expected output for a negative input: Released: resource still prints, in both cases, in the same
relative position (right before the function actually exits) – whether process falls all the way through to the
bottom or exits early through your new return. That’s RAII’s actual guarantee made visible: g’s destructor is
tied to g going out of scope, not to any particular line of code reaching the bottom of the function. You don’t
write anything to make Released: resource appear in the early-return case – it already does, for free, the
moment g’s scope ends.