The C++ Boost Libraries (Part 1 - Introduction)

Andrew Stephens, Tuesday the 13th of January, 2009

Although I like to think of myself of a jack-of-all-programming-trades, I must admit that I am mainly a C++ man This post was automatically imported from my old sandfly.net.nz blog. It may look a little weird since it was not originally written for this format.. I have dabbled in the seductive dark side of Java and C#, but still prefer the mad poetry that C++ code can generate. A few years ago, C++ was showing signs of its advanced years but this has changed with the Boost libraries - a set of weird and wonderful additions to the C++ standard libraries that really bring C++ into the current century. I have been using boost for over a year, and I cannot claim to have scratched its surface. The parts that have found their way into my projects have all been well engineered and easy to use - each library goes through a lengthly review process before being part of the Boost distribution. It obviously pays off - several boost libraries are to be standard features of C++0x.

The Boost libraries fall into 3 main categories:

Not all of Boost is ridiculously arcane and subtle. Take, for instance, the humble boost::logic::tribool class. From the documentation - "A tribool implements 3-state boolean logic" - which is useful for situations like the following:

boost::logic::tribool godExists = detectGod();
if (godExists)
    std::cout << "Good news - there is a God\n";
else if (!godExists)
    std::cout << "Good news - there is no God\n";
else
    std::cout << "There may or may not be a God\n";

See what I was saying about mad poetry.