I just finished reading Beyond the C++ Standard Library: An Introduction to Boost. A really interesting read. Some of the more interesting things that I picked up:
boost::shared_ptr– likeauto_ptron steroids, a very nice reference-counted smart pointer. Not only can it clean up memory allocated with new, but you can pass in a custom deleter and thus use it to clean up anything, such as close a file or database connection, etc. The book also coversshared_array, intrusive_ptr, weak_ptr, scoped_ptr,andscoped_arrayboost::numeric_castcan warn you when you’re casting a number to a smaller number type that will truncate.boost::lexical_castcan convert back and forth between strings and numbers, thereby accomplishing in one concise line, conversions that I normally do with a few lines ofstringstreamcode.boost::regexcan do all kinds of interesting things with regular expressions.boost::anyis an interesting variant type that allows storing several types of values, but is type-safe in the sense that it makes the caller specify the correct type in order to gain access.boost::tupleis a logical extension ofstd::pairand allows a nice way to get multiple return values from a function:boost::tuple
gcd_lcm(int val1, int val2); ... boost::tie(gcd, lcm) = gcd_lcm(15, 20); boost::signalis an interesting “signals and slots” (or “publish and subscribe” or callbacks) implementation.