The next iteration of the C++ standard passed the ISO technical committee review earlier this year and is scheduled to be approved this fall. This version of the specification is now referred to as C++11 (a reference to the year it will be approved). Jim Humelsine recently sent me the following link that provides a neat table of the new features of C++11, along with the status of their implementation in the gcc compiler. This resource was put together by George Flanagin and provides a succinct overview of the new features of C++11 as well as a great reference for those interested in trying some of these out in their own code. As I describe in my book, many of these new features allow for better C++ API designs.
The Standard Template Library
Thursday, September 9th, 2010 |
The Standard Template Library (STL) provides a collection of containers, iterators, algorithms, and functors for C++. This is perhaps the most famous and widely-used C++ API. It provides template-based containers such as std::string, std::vector, std::map, and std::set, which you can specialize with your own types (std::string is of course already specialized for characters). The STL is therefore a good place to look for an example of compile-time polymorphism in C++. The authoritative documentation is the STL programmer’s guide from SGI:
Boost C++ Libraries
Thursday, September 9th, 2010 |
The Boost libraries are a collection of open-source libraries that extend the functionality of C++. Many of the Boost founders are active in the C++ standards committee and as a result several of the Boost libraries have been included in the new C++ ISO standard (C++0x), including smart pointers, function object binders, type traits, and tuples. You’d have to go a long way before you find better examples of modern C++ API design.
You can also find a good overview of the Boost libraries on Wikipedia.
Intel’s TBB Library
Thursday, September 9th, 2010 |
Intel provides the Threading Building Blocks (TBB) as an open-source library to make it easier to write multithreaded C++ code. This library offers some good examples of C++ API design, including the use of namespaces, templates, containers, iterators, and parallel programming patterns. The TBB library works for Windows, Mac OS X, and Linux.
Alexandrescu’s Loki Library
Wednesday, September 8th, 2010 |
Andrei Alexandrescu published an excellent book called “Modern C++ Design.” In this book, he introduced the notion of policy-based templates as a way to provide highly-configurable solutions to various design patterns. He made the source code for these templates available via his Loki library, available at: