The C++ Standard Library

Rating: 4/4 (A gentle introduction and a must-have reference for all C++ programmers.)

One of the love-hate features of C++ is the standard library. A predominantly large part of the library is the Standard Template Library (STL), which consists of containers, iterators and algorithms. The C++ programmer combines these classes to write his application. Due to the size of the library, the number of classes and functions and their odd eccentricities, a good reference is needed to use it properly. Thankfully, the The C++ Standard Library (A Tutorial and Reference) by Nicolai M. Josuttis is up to the job. This is probably the C++ book which I have used the most in the past few years.

The containers, iterators and algorithms of the STL use template metaprogramming heavily. However, learning this is still quite an uphill task for most programmers. I love this book because it cleanly sidesteps that part of C++, while still being to introduce and provide a compendium of usage of the STL classes. The reader only needs to read and understand the introductory chapters. The rest of the book serves as a reference to lookup when he actually faces a task that needs a container or algorithm. Chapter 6 (Containers) and Chapter 9 (Algorithms) are what I refer to most frequently almost every day. There are very few books which deal with the C++ standard library, thankfully this one is very good! The C++ Standard Libary is a must-have reference for all C++ programmers.

Advertisements

Effective STL

Rating: 3/4 (Recommended for the bookshelf of any STL user)

I find myself using STL a lot in my C++ code. I also found that I was continuously rewriting the STL code, every time I discovered subtle bugs in the way I was using it or when I found a more elegant solution to the same problem. Looking around for wisdom on STL, I picked up Effective STL by Scott Meyers. Scott has authored two other books: Effective C++ and More Effective C++, both of which I have found to be approachable and useful.

Like the other books in the Effective series, this one too has 5x chapters or items, as they are called. The topics they deal with include containers, iterators, algorithms and functors. The whole area of extending STL has been skipped and left for other books. Each item in the book is self contained with a title, introduction, examples, explanations, guidelines and sometimes even trivia. I found the book very useful, showing up mistakes in my code and also sharing a lot of idiomatic methods to write what I wanted. While reading the book, I found myself compelled to go back to my code and start polishing it immediately! Much like the other Effective books by Meyers, Effective STL too is really easy to read, understand and apply. Recommended for the bookshelf of everyone who uses STL.

Related: My notes from this book can be found here.

Blog at WordPress.com.