Item 19. Uncaught Exceptions

I l @ ve RuBoard

Difficulty: 6

What is the standard function uncaught_exception() , and when should it be used? The answer given here isn't one that most people expect.

  1. What does std::uncaught_exception() do?

  2. Consider the following code:

     T::~T() {   if( !std::uncaught_exception() )   {     // ... code that could throw ...   }   else   {         // ... code that won't throw ...       }     } 

    Is this a good technique? Present arguments for and against.

  3. Is there any other good use for uncaught_exception() ? Discuss and draw conclusions.

I l @ ve RuBoard


More Exceptional C++
More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions
ISBN: 020170434X
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Herb Sutter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net