Chapter 18. Constructor Failures, Part 2: Absorption?

Difficulty: 7

This Item analyzes constructor failures in detail, shows why the C++ rules should work the way they do, and demonstrates the implications for constructor exception specifications.

  1. In Item 17 Example 17-1, if the A or B constructor throws an exception, is it possible for the C constructor to absorb the exception and emit no exception at all? Justify your answer, explaining by example why this is as it should be.

  2. What are the minimal requirements that A and B must meet in order for us to safely put an empty throw-specification on C's constructor(s)?

Solution

Solution

I Can't Keep No Caught Exceptions ...

Get More Exceptional C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.