Hacker News new | past | comments | ask | show | jobs | submit login

> AIUI exceptions and RAII are mutually exclusive in C++

That is... very wrong. Exceptions are perilous unless you use RAII religiously (which you should; it's good.)

For more information, read up on RAII and search for "exception safety."

The definition of C++ RAII from Wikipedia: "In this language, if an exception is thrown, and proper exception handling is in place, the only code that will be executed for the current scope are the destructors of objects declared in that scope". Without this it is very hard to reap any benefits of exceptions (people have disagreements on what those are, if any, but that's another topic).




Up-voted a few of the others below too.

I also found this which I thought was a high quality summary: http://www.parashift.com/c++-faq-lite/ctors-can-throw.html




Applications are open for YC Winter 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: