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:
> >
> > http://groups.google.com/groups?selm=3E76FB8A.A9C88386%40web.de
> > (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.

http://groups.google.com/groups?selm=3D32A955.6E5039E%40web.de
(Subject: Re: Is internal catch-clause rethrow standard?)

Well, you may also rely on ES:

<copy&paste>

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 {
  checked_oper_call();
}
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( /* ... */ );
}

</copy&paste>

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.

No. http://groups.google.com/groups?selm=3EC258F8.AE7DF214%40web.de

> 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.

regards,
alexander.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk