Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-10-09 09:14:17


Alexander Terekhov wrote:
> Peter Dimov wrote:
>> Meaning "no, if there is throw() specification somewhere"? Duh. Of
>> course.
>
> Not necessarily throw().
>
> void oper() throw(int) {
> /**/
> fclose(/*..*/); // doesn't throw; cancel is unexpected
> }
>
> void oper() throw(int) {
> /**/
> try {
> fclose(/*..*/); // can throw; cancel IS expected
> }
> catch (std::thread_cancel_request const &) {
> /**/
> std::enable_thread_cancel(); // re-enable cancel state
> std::thread_self().cancel(); // re-inject cancel request
> /**/
> }
> }

OK. You want to use an exception specification that does not contain
thread_cancel_request as "syntactic sugar" for disable_cancelation. Why is
ES better than RAII in this context? What makes this technique useful for
other situations that involve a different kind of exception?


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