On Wed, Jul 15, 2009 at 10:10 AM, Alex Black
You mentioned never throwing exceptions in destructors - sounds like good advice, thx. Two points though: 1. If an exception is thrown in a destructor can it not be caught with a try catch( ... )?
If a destructor calls functions that may throw, it should use catch(...) and not let exceptions propagate out of the destructor itself. However, when writing or sending data, the user may want to know that the operation has completed successfully. Typically, you'd provide a separate flush function for that use case, which you'd then call in the destructor, as in: foo_sender::~foo_sender() { try { flush(); } catch(...) { } } Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode