> RAII is not useful if it results in code that's less clear about the possibility of leaks
> than that which it replaces.
In this case (and in general) RAII minimizes the possibility of leaks now and in the future.
A reasonable alternative approach not using RAII, like r1120 on development-branch, is both more cumbersome than this and is not future-proof. What if the function gradually gets more complicated? What if someone inadvertently adds a return? We didn't catch this last time, we may not catch it the next.
Plus, we are using RAII/smart pointers all over the place, I don't see a reason to make an exception here.
> RAII is not useful if it results in code that's less clear about the possibility of leaks
> than that which it replaces.
In this case (and in general) RAII minimizes the possibility of leaks now and in the future.
A reasonable alternative approach not using RAII, like r1120 on development-branch, is both more cumbersome than this and is not future-proof. What if the function gradually gets more complicated? What if someone inadvertently adds a return? We didn't catch this last time, we may not catch it the next.
Plus, we are using RAII/smart pointers all over the place, I don't see a reason to make an exception here.