|
Boost : |
Subject: Re: [boost] Proposed new RAII Library
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2012-09-14 21:27:43
On 14/09/12 19:33, Sergey Cheban wrote:
> 14.09.2012 22:48, Sohail Somani пиÑеÑ:
>
>> Or in C++11:
>>
>> boost::scope_guard lolwhat( [&](){ CloseHandle(handle); } );
>>
>> ...
>> lolwhat.dismiss();
> What about
> boost::exception_guard somename( [&](){ CloseHandle(handle); } );
> that calls the function/lambda only if std::uncaught_exception() returns
> true?
std::uncaught_exception is very dangerous to use in this way. See
http://www.gotw.ca/gotw/047.htm
In short: your function will misbehave if called from a destructor
during stack unwinding.
John Bytheway
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk