REVIEW - Exceptional C++ - 47 Engineering Puzzles, Programming Problems, and Solutions


Exceptional C++

47 Engineering Puzzles, Programming Problems, and Solutions


Herb Sutter



Addison-Wesley Professional (2000)




Alan Griffiths


April 2000



Let me save you some time: if you are interested in making effective use of C++ then this is a good book, buy it!

Let me save you some time: if you are interested in making effective use of C++ then this is a good book, buy it!

Oh, you want to know more...

Over two thousand years ago Plato describes how the philosopher Socrates experimented with a form of teaching based on the student answering a series of questions that leads them to a new insight. Since the mentor never directly teaches this insight Socrates concluded that the student must, at some level, have already known it. The mentor only serves to remind the student of this knowledge.

If you work through the problems in Exceptional C++ you will be surprised at how much you already know about C++.

Herb Sutter has been honing his question setting skills with his regular "Guru of the Week" postings to comp.lang.c++.moderated. These take the form of puzzles to be tackled by "all comers" and the author of the best answer is pronounced "Guru of the Week". These puzzles are grounded in the issues raised by trying to do software engineering in C++. Anyone that has set questions for a quiz will appreciate the amount of work that goes into setting such an exercise.

It has to be said that a fair proportion of the material in the book has already appeared on usenet. However it has been reworked into a more extended form to isolate the individual points and to develop themes. On the occasions the contributions made by others on usenet have been included in the book these contributions are acknowledged.

The book is no mere collation of usenet postings. Not only have the opportunities for improving the presentation in book format been exploited but there is also a significant amount of new material.

There are forty seven questions in the book arranged into eight thematic chapters. These have a broad range but are all of relevance to the practicing C++ developer...

"Generic Programming and the C++ Standard Library" covers a variety of ways in which the the standard containers, iterators and algorithms interact and can be adapted. In the midst of all this there is an answer to the perennial question of creating a "case insensitive string" class.

"Exception-Safety Issues and Techniques" develops many of the techniques required to write exception safe code - and more importantly an understanding of the various levels of exception safety and the engineering trade-offs between them. This is the only section in which I've found a significant error - in a question on code complexity I found 31 paths out of a claimed maximum of 23 (Herb actually counts branch points, not paths - and I'd missed some).

"Class Design and Inheritance" deals with the principles of class design. Various abuses of inheritance, operator overloading, and composition techniques are explored in the context of improving the design of code fragments.

"Compiler Firewalls and the Pimpl Idiom" explores techniques for managing the physical dependencies between translation units. (That means minimising the number of secondary headers included in each header file.) "Name Lookup, Namespaces, and the Interface Principle" expores the ways in which scopes interact for the compiler to find the named function or class. Some of these interactions are surprising, and some are problematic, but working through these examples you will come to understand the rationale behind the current rules.

"Memory Management" develops guidelines for managing the various types of memory used in C++ (did you know there are five?).

The remaining sections "Traps, Pitfalls, and Anti-Idioms" and "Miscellaneous Topics" don't have unifying themes, but are still full of challenging points.

To get full value from this book you must be willing to stop and think about the questions as they are posed. The format doesn't help with this, since the solutions often follow immediately. It can sometimes be hard to stop the eyes drifting. Without years of practice with Bridge books many of which have the same problem I doubt that I'd have managed as well as I did.

Personally I'd favour an extra couple of dozen pages strategically inserted so that the questions always appear alone on the right hand page. But this is a minor quibble with an excellent book. I look forward to the sequel.

Book cover image courtesy of Open Library.

Your Privacy

By clicking "Accept All Cookies" you agree ACCU can store cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

By clicking "Share IP Address" you agree ACCU can forward your IP address to third-party sites to enhance the information presented on the site, and that these sites may store cookies on your device.