Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2003-10-08 16:47:14

Peter Dimov wrote:
> Right. There is only one way to convert a potentially throwing operation
> into a nothrow operation, and that's by ignoring exceptions.

Why don't you simply catch KNOWN & EXPECTED exception(s) that you want
to swallow?

> > Now, please click here:
> >
> >
> > (Subject: Re: [OT] Re: C++ object locks like Java?)
> I did. The example where the exception thrown by the reset() method of a
> smart pointer is ignored is legitimate. This is not "blind use of
> catch(...)".

Sure it is. You can catch pthread_stackovf_e and never actually
do a reset, to begin with.
(Subject: Re: Is internal catch-clause rethrow standard?)

Well, you may also rely on ES:


That's not the only use of ES. Brain-dead mandatory unwinding aside,
another use of ES is this: < for example >

void oper(); // could throws anything

void checked_oper_call() throw( SOME_KNOWN_EXPECTED_EXCEPTIONS )
{ oper(); }

try {
catch( ... ) // I know what I am doing/getting here,
             // just do not want to write many catch
             // clauses; simply handle it using the
             // "try { throw; } catch..."-idiom.
  handle_it( /* ... */ );


He we can noop "handle_it" (of course, pthread_stackovf_e beast shall
be suppressed by a restricting ES for any cleanup stuff... unless you
can live with leaks ;-) ).

> But what does it mean for a cancel exception to be unexpected, from a
> language point of view? A cancel exception always has a handler, its handler
> cancels the thread. std::expected_exception<> will always return true for
> it.


> I'd rather have std::exceptions_allowed() that returns false in a
> destructor or a throw() function.

std::unwinding(T *) together with std::expected_exception<T>() (T can
be void meaning "something/unspecified") is almost all what you need.


Boost list run by bdawes at, gregod at, cpdaniel at, john at