Re: Throw from a destructor
Noah Roberts wrote:
Thanks guys. Here's why I asked the question.
Some C++ test rigs support an explicit setUp() and tearDown() for their test
fixtures.
Some (despite being written by authors of books on C++) only provide the
constructor and destructor of the fixture.
I had to make a case for always providing tearDown(). For example, my
current project must call orb->shutdown() after each test case, and that
might throw. I need the throw reliably caught, without impossible
ramifications.
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Noah Roberts wrote:
It is impossible to write exception safe code if any destructor can
throw. Destructors must therefore ALWAYS have the no-throw guarantee.
If this means having catch(...) then so be it...never allow exceptions
to escape a destructor...ne ver.
throw. Destructors must therefore ALWAYS have the no-throw guarantee.
If this means having catch(...) then so be it...never allow exceptions
to escape a destructor...ne ver.
Some C++ test rigs support an explicit setUp() and tearDown() for their test
fixtures.
Some (despite being written by authors of books on C++) only provide the
constructor and destructor of the fixture.
I had to make a case for always providing tearDown(). For example, my
current project must call orb->shutdown() after each test case, and that
might throw. I need the throw reliably caught, without impossible
ramifications.
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Comment