C++ Logo

std-proposals

Advanced search

Re: [std-proposals] fine-control exception/error/UB handling on function boundary

From: Bjorn Reese <breese_at_[hidden]>
Date: Fri, 28 Aug 2026 14:43:37 +0200
On 8/28/26 10:38, Tiago Freire via Std-Proposals wrote:

> And I would kill to be able to specify a list of possible exceptions at
> the interference level to be able to validate the code is exception safe.

You can emulate the deprecated exception specifications.

For example

   void foo() throw(A, B) {
     // do stuff
   }

can be written as

   void foo() try {
     // do stuff
   }
   catch (A) { throw; }
   catch (B) { throw; }
   catch (...) { std::terminate(); }

Admittedly more verbose, but it makes the run-time overhead clear.

Received on 2026-08-28 12:43:45