C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Try-catch declaration

From: Fabio Alemagna <falemagn_at_[hidden]>
Date: Wed, 22 Nov 2023 12:54:26 +0100
Il mer 22 nov 2023, 12:50 sasho648 via Std-Proposals <
std-proposals_at_[hidden]> 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.

>

Received on 2023-11-22 11:54:40