Because I only care about the exception thrown at `func()` and don't want to have exception handling for the rest of  the code.

On Wed, Nov 22, 2023 at 1:54 PM Fabio Alemagna <falemagn@gmail.com> wrote:


Il mer 22 nov 2023, 12:50 sasho648 via Std-Proposals <std-proposals@lists.isocpp.org> ha scritto:
Ok use-case I was thinking is actually:

int f() {

try (auto &ref = func()) {
} catch(...) {
return -1;
}

// use ref here
}

Why would you want to use ref after the whole try-catch block?

If func() does't throw, you can use ref right after its call, within the try block itself.