C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Try-catch declaration

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Wed, 22 Nov 2023 12:47:00 +0100
Il 22/11/23 12:31, sasho648 via Std-Proposals ha scritto:
>
> So in my experience the biggest issue I had with using try-catch is for
> example when I try to construct a reference within try-catch - in order
> to capture only the exception that could occur there:
>
> try {
> auto &ref = func();
> }
> catch(...) {
> }
>
> Problem here is:
>
> You either have to use reference wrapper or something like that if you
> want to handle only the exception that could potentially be thrown by
> func. And still it would be ugly.

But what should `ref` refer to if `func()` throws?

Thank you,
-- 
Giuseppe D'Angelo

Received on 2023-11-22 11:47:04