Boost is a free library which is aimed at providing quality software components to developers, whilst using the styles of the Standard Template Library. Some of the components within the library may be put forward as future extensions to the Standard Library.

The Boost homepage contains extensive documentation on all of the individual components. This article is intended to be an overview of why you should consider using Boost, and the Boost components in preference to other libraries, and to provide a location on CodeProject which can offer links to related documentation.

Boost installation is simple because most of the components within the library reside in their own header files, which should not require modification. The BoostJam build tool is available for the components which do require compilation.

Unzip the entire archive into a directory of your choosing. To start using the components add the Boost directory which includes version numbers to your include path. For the current version of Boost, boost_1_30_0.

Boost supports a variety of compilers, operating systems and standard libraries. It provides workarounds for the broken features of many compilers, perhaps the most significant being the workarounds for problems with templates, including partial template specialisation and member template friends.

Regression testing. Each update to Boost is heavily regression tested, and the status of the library for all compilers is freely available.

Many of the people involved with the development of the C++ standard are involved with Boost.

Simple to install and upgrade. In most cases, installation and upgrading only requires the addition or change of one include path.

Easy to configure. Compilation options can be specified by changing directives in one or two header files.

What follows is a minimal listing of components. There are about 50 major sub-components in Boost at the moment. The following components were those that I felt logically progressed from the components in the STL, were easy to integrate, or were especially significant to most programmers.

Smart pointers are tools that prevent resource leaks (especially in the presence of exceptions), promote the concept of 'Initialisation is Resource Acquisition'. They emulate, to a certain extent, garbage collection like behaviour.

Most of the limitation of std::auto_ptr are relatively well known:

std::auto_ptr's cannot be stored within a standard containers.

std::auto_ptr's cannot (easily) be used to implement the pImpl (pointer-to-implementation) idiom.

std::auto_ptr does not work with arrays.

The 5 types of Boost smart pointers overcome these flaws and provide many extra features.

Functors and binders have become a common part of using the STL, but using most standard library implementations it can still be difficult to combine multiple functions. Composers allow functors to be combined in several ways, minimising the amount of times that users have to write their own loops.

A component which provides a type safe way to move any type of component, without having to rely upon void pointers or unions. The design principles for this component is at least as significant as the component itself (derivation of a template class from a non template base class). Something similar to boost::any appears in Alexandrescu’s Modern C++ Design in the guise of Functors and Functor Implementations.

The lambda library provides a shortcut for producing binders, functors and composers using expression templates. My personal opinion on the library is that developers would need some practice to recognise it’s use. Libraries like the Lambda library are probably the way of the future for C++, but at the moment, I think I’m prepared to have slower uglier code that I know the next guy can understand.

The Boost Lambda Library IndexFurther information on the basics of expression templates was published in the March issue of the C/C++ users journal (C++ Expression Templates – Angelika Langer and Klaus Kreft)

The BGL is a huge library, with a large amount of support material and good sample programs. “The Boost Graph Library, The: User Guide and Reference Manual” has been published by Addison-Wesley in the C++ In Depth Series (The same fantastic series that includes 'Exceptional C++', 'More Exceptional C++' and 'Modern C++ Design'), which I believe is testament to the quality of the library.

Developed by Code Project regular William E. Kempf, the threads library makes it seem almost as easy to do threads in C++ as it is in Java. It requires linking to an additional library, built with BoostJam.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

Share

About the Author

Andrew is a PhD student at Swinburne University in Melbourne Australia, investigating the control systems of UUV's - Unmanned Underwater Vehicles. He graduated from Swinburne with a Bachelor of Engineering (Robotics and Mechatronics) and a Bachelor of Science(Computer Science & Software Engineering)

His practical experience includes a year developing an industrial computer vision system from scratch, and working as the software architect for the 2004 Swinburne Robocup team (f180 league).