Herb Sutter is a recognized expert on C++ software development and regularly gives Exceptional C++: 47 Engineering Puzzles, Programming Problems, and. Aimed at the experienced C++ programmer, Herb Sutter's Exceptional C++ tests the reader's knowledge of advanced C++ language features and idioms with. Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions. 3 reviews. by Herb Sutter. Publisher: Addison-Wesley Professional. Release.


Author: Marcus Prohaska
Country: Haiti
Language: English
Genre: Education
Published: 6 October 2015
Pages: 466
PDF File Size: 1.80 Mb
ePub File Size: 25.21 Mb
ISBN: 433-3-99513-117-5
Downloads: 74854
Price: Free
Uploader: Marcus Prohaska


Finally, you will likely exceptional c herb sutter better performance, because contracts should enable compilers to perform more optimizations, more easily, than expressing them using assertions. They also include expects preconditions and ensures postconditions, which are part of the function declaration and so are visible at call sites: Preconditions are usually enforced at the call site, which is what we want most of the time because a precondition violation always means a programming bug in exceptional c herb sutter calling code.

But preconditions can also be enforced in the callee, which can sometimes be necessary for pragmatic reasons, such as when the function is invoked through an opaque function pointer.

Preconditions and postconditions that are known at the call site also give the optimizer more information to potentially make your code fast. That statement might exceptional c herb sutter you, so let me elaborate why I think so.

Step 2 is to gradually migrate std:: The programming world now broadly recognizes that programming bugs e. Note that in the near term, the idea is for implementations to be allowed, but not required, to use contracts.

Guru of the Week and the Exceptional C++ Series | Sutter’s Mill

We are bringing the community forward gently here. Why is step 2 so important?


Gradually switching precondition violations from exceptions to contracts promises to eventually remove a majority of all exceptions thrown by the standard library! This principle applies across programming languages; for examples, in Java and.

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions by Herb Sutter

Being able to eliminate a majority of all exceptions, which eventually enables many more functions to be noexcept, is a huge improvement for both correctness and performance: It eliminates a majority of the invisible control flow paths in our code.

For example, over 20 years ago Exceptional c herb sutter wrote GotW 20 [ Sutter ] that shows how today a 4-line function has 3 normal execution paths and 20 invisible exceptional execution paths; if we can eliminate a majority of the functions that can throw, we immediately remove a majority of the invisible exceptional c herb sutter execution paths in functions like this one, in all calling code.

More noexcept enables more optimization and faster code. You knew that was coming, right? Once you change all preconditions and postconditions and assertions from exceptions to contracts, eliminating some of the largest categories of exceptions, one specific kind of exception dominates all others: Which brings us to step 3… Step 3 is to consider handling heap exhaustion out-of-memory, OOM differently from other errors.

You may be at a point in your journey where you have become numb to this fact. But then reading this series you think about: The Pimpl idiom, a huge mess of a method to get boxed objects invisible and automatic in every language of the exceptional c herb sutter 20 years 2.


Ridiculous template error messages 5. And in every single GotW, no matter how short, it just felt right to: For example, GotW 6 about const-correctness is now a two-parter, covering the new meanings of const and mutable.

Related Posts: