Review of Pete Becker’s TR1 Book

2006-12-14, , Comments

If you’re a C++ programmer, you should know that Pete Becker has written a tutorial and reference book on the first C++ Library Technical Report (more commonly known as TR1). I recently reviewed this book for ACCU.

Book Details

  • Title: The C++ Standard Library Extensions: A Tutorial and Reference
  • Author: Pete Becker
  • Publisher: Addison Wesley Professional
  • ISBN: ISBN-13: 978-0-321-15962-5


The standard C++ library is a fine thing but there are some notable omissions and weaknesses: there are no hashed containers, few smart pointers, no standard regular expression library; support for gluing functions and algorithms could be improved on; and so on. The first C++ Library Technical Report (TR1) addresses these issues and many more. In 2006 the TR1 library was approved by ISO, and you can already find TR1 implementations. Pete Becker’s book provides a comprehensive and accurate reference guide for the TR1 library.

The book styles itself as the perfect companion to Josuttis’ “The C++ Standard Library”, and that’s what I hoped for — a book which would cut through the standardese and provide clear instructions on how I could benefit from TR1. In the main, it succeeds. There’s plenty of example code, and there needs to be — TR1 gives the standard C++ library a sizeable boost. The code is clearly written and described, and available for download from the author’s website. The examples I tried (using GCC 4.01) worked, though I had to fiddle a little with include paths. Pete Becker has first-hand knowledge of implementing TR1, giving this book an authorative tone. I can imagine this book becoming The TR1 Book and I would certainly recommend it.

I do have some niggles, though. More attention could have been given to the layout. The code examples often break awkwardly across pages and some form of syntax highlighting would have made them more readable. I can’t understand why the output from these programs was either omitted or buried in a paragraph of explanatory text. Code comments were abused throughout the book to provide a running commentary. E.g.

tuple<> t0;        // default constructor
tuple<int> t2(3);  // element initialised to 3

I realise this is common practice in programming books, but I’d like to see authors and publishers find a better way to annotate code.

These are niggles, though. My only real complaint was that many of the examples failed to show the benefits of using TR1. Much of TR1 is designed to make C++ easier to use; it’s easier to manage dynamically allocated objects, it’s easier to bind function arguments, it’s easier to wrap functions for use in standard algorithms. The examples showed how to get TR1 code up and running, but sometimes failed to explain why.