Effective C++ Ed. 3rd: Item 29. Strive for exception-safe code

When an exception is thrown, a exception-safe fuction:
  • Leak no resources
  • do not make data structures corrupt.
Exception-safe functions should offer one of three guarantees:
  • the basic guarantee
  • the strong guarantee
  • the nothrow guarantee
Results:
  • Although the strong guarantee is not always practical, but where possible it can be offered via copy-and-swap."pimple idiom" may also be used here.
  • As said, "A chain is only as strong as its weakest link". A function can usually offer a guarantee no stronger than the weakest guarantee of the functions it calls.
prev | next
Cheers and try hosting at Linode.

    No comments:

    Post a Comment