Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Usage

Whether to use Your Native TR1 Library
Header Include Style
Writing Code

There are two things you need to decide before using the Boost.TR1 library: whether to use your standard library's native TR1 implementation (if it has one), and which include style to use.

If your standard library implements the TR1, and you want to make use of it, rather than use the Boost equivalents, then you will need to take some explicit action to enable it: this may be a pre-processor define, a special compiler switch, or a different include path. You will need to consult your compilers documentation to find out which of these actions you need to take.

Provided Boost is correctly configured, everything should now "just work", and code written to use Boost.TR1 will include your standard library's native headers rather than the Boost ones.

There are two ways you can include the Boost.TR1 headers, for example if you are interested in shared_ptr then you can either use:

#include <boost/tr1/memory.hpp>

or:

#include <memory>

The first option is the preferred method for other Boost libraries to use. The second option is standard-conforming, but requires that you add boost-install-path/boost/tr1/tr1 to your compiler's include search path. Note that you must not copy the headers in boost/tr1/tr1 into a directory called "include", doing so will cause them to cease working.

Regardless of how the includes are setup, user code written to work with Boost.TR1 is exactly the same as code written to use a native tr1 implementation. That is, references to classes and functions need to explicitly use the std::tr1 namespace or a using std::tr1 statement. For example,

std::tr1::tuple<int, std::string> t = std::tr1::make_tuple(10, "hello");

or

using std::tr1;
tuple<int, std::string> t = make_tuple(10, "hello");

PrevUpHomeNext