
15 Sep
2012
15 Sep
'12
1:27 a.m.
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