Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: anchor links

...

It is generally recommended that constructors that cannot complete their job should throw exceptions rather than exit normally and leave their object in an incomplete state [Cline 200909].

Resources must not be leaked as a result of throwing an exception, including during the construction of an object.

...

Bibliography

[Cline 200909]

Question 17.2, I'm still not convinced: A 4-line code snippet shows that return-codes aren't any worse than exceptions;
why should I therefore use exceptions on an application that is orders of magnitude larger?

[ISO/IEC 14882-2014]Subclause 15.2, "Constructors and Destructors"
[Meyers 96]Item 9, "Use Destructors to Prevent Resource Leaks"
[Stroustrup 2001]"Exception-Safe Implementation Techniques"

...