More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions

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

Категории