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

Click here to view the latest version of this page.
PrevUpHomeNext

Usage

Whether to use Your Native TR1 Library
Header Include Style

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.

Whether to use Your Native TR1 Library

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.

Header Include Style

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.

Important Note #1

The include path order is very important if you want this library to work correctly. If you get compiler errors then suspect the include paths. The correct order is:

1) boost-root/boost/tr1/tr1
2) boost-root
3) Any other standard library replacements (STLport for example).
4) Your regular standard library.
Important Note #2: Borland C++ Users

Borland's compiler has a particularly broken form of #include, that will actually look for a file named array.h if you #include<array>. In order to make this library work with Borland's compiler you will need to set up the include paths as follows:

1) boost-root/boost/tr1/tr1/bcc32
2) boost-root/boost/tr1/tr1
3) boost-root
4) Any other standard library replacements (STLport for example).
5) Your regular standard library.
Important Note #3: Sun C++ Users

Sun's compiler has a particularly interesting form of #include, that will actually look for a file named array.SUNWCCh if you #include<array>. In order to make this library work with Sun's compiler you will need to set up the include paths as follows:

1) boost-root/boost/tr1/tr1/sun
2) boost-root/boost/tr1/tr1
3) boost-root
4) Any other standard library replacements (STLport for example).
5) Your regular standard library.
Copyright 2005 John Maddock

PrevUpHomeNext