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.
In Item 17 Example 17-1, if the
A
orB
constructor throws an exception, is it possible for theC
constructor to absorb the exception and emit no exception at all? Justify your answer, explaining by example why this is as it should be.What are the minimal requirements that
A
andB
must meet in order for us to safely put an empty throw-specification onC
's constructor(s)?
Solution
I Can't Keep No Caught Exceptions ...
Get More Exceptional C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.