C++ is a dynamic and growing programming language. After the last version of the C++ Standard (approved in the fall of 1998, and revised in 2003), many C++ programmers immediately started working on the next one. They realized that, versatile and powerful though it might be, C++ still lacked some features that programmers would like to have. At the time of this writing (summer, 2008, nearly ten years later), the next version of the C++ Standard is nearing completion, and some vendors have already implemented major parts of that upcoming standard. In particular, the Visual C++ available in Visual Studio 2008 will contain an implementation of the TR1 library (see below), once you have installed the "Visual C++ 2008 Feature Pack", which was released after Visual Studio 2008 itself.

The Technical Report 1 (TR1) Library

There is a document called Technical Report 1 (generally referred to by the shorter "TR1") from the Library Subcommitte of the C++ Standardization Committe. It contains descriptions of the new library functionality to be added to C++ in the next round of standardization. Note that these are library changes only, and there will also be changes to the C++ core language itself in this next round.

For further information on TR1 as well as changes to the core language, see the On-Line References section below.

And look here for some sample programs illustrating TR1 features.

The Boost Library

Let's start our discussion of the Boost C++ Library (actually a collection of libraries) with the following quote from the FAQ page of the Boost web site (see On-Line References below):

Where does the name "Boost" come from? Boost began with Robert Klarer and I fantasizing about a new library effort over dinner at a C++ committee meeting in Sofia Antipolis, France, in 1998. Robert mentioned that Herb Sutter was working on a spoof proposal for a new language named Booze, which was supposed to be better than Java. Somehow that kicked off the idea of "Boost" as a name. We'd probably had a couple of glasses of good French wine at that point. It was just a working name, but no one ever came up with a replacement. (Beman Dawes)

Whatever the origin of its name, the Boost Library has become a welcome source for functionality missing from the current C++ Standard. The library is designed to be compatible with the Standard, and many of those involved in its development are in fact members of the Standard Committee. It is therefore not surprising that a number of the facilities offered by Boost are slated to make their way into the next version of the C++ Standard.

The Boost learning curve is somewhat steep and, although some texts are starting to appear on the subject, at the time of this writing (summer, 2008) there are few resources providing a readily accessible "elementary" introduction for undergraduates to any parts of the library. [One notable exception is the latest edition of "C++ How to Program" from the Deitel series, published by Prentice Hall.] At the very least, one needs to be reasonably comforable with templates, and it helps to have seen and used some of the things that the average undergraduate C++ student may not have seen, such as the pair struct and various STL features. Not that pairs in and of themselves are a difficult concept; it's just that if the first time you see a pair, it's in the middle of whatever else may be going on with Boost, it doesn't help matters.

For further information on Boost, see the On-Line References section below.

And look here for further information and some sample programs illustrating Boost features.

So, which to use ... TR1 or Boost?

Because there is overlap in the facilities provided by TR1 and Boost, the question of which to use when one has a choice obviously arises. The reason for this overlap is that some of the features that appear in TR1 have their origin in Boost, but such features may not be exactly the same in both libraries. Because TR1 is likely to be closer to the eventual standard, as a rule of thumb you should probably use TR1 in preference to Boost when you have the opportunity to do so.

How to Use TR1 in Visual C++ 2008

The first thing you need to do to use TR1 in Visual Studio 2008 is to install the Visual Studio 2008 Feature Pack. [See the link in the On-Line References section below.] Once you have done this, you need only #include the appropirate header(s) in your code to make use of whatever feature(s) you need from the TR1 libraries.

How to Use Boost in Visual C++ 2008

The first thing you need to do to make use of the Boost libraries in Visual Studio 2008 is to make sure that those libraries are installed on your system, since they are not automatically present in Visual Studio 2008. In order to perform that installation, if it is required, go to the Boost home page (see the link in the On-Line References section below), from which you can download and install the latest version of the Boost libraries. As of early summer, 2008, this was version 1_35, and it should be said that this latest version is much easier to install than some of the previous versions.

The default install location for Boost will be this:

C:\Program Files\boost

but you must also make sure that Visual Studio 2008 knows where to find the things it will need. In particular, Visual Studio 2008 will need to know where to find the Boost include files and the Boost library files. If you have installed Boost in the default location as above, then you need to fire up Visual Studio 2008 and make the following changes:

  1. Under Tools | Options | Projects and Solutions | VC++ Directories choose Include files in the Show directories for: drop-down box and add a line containing the following path:
    C:\Program Files\boost\boost_1_35_0
    
    or whatever the appropriate number is for your version.
  2. Under Tools | Options | Projects and Solutions | VC++ Directories choose Library files in the Show directories for: drop-down box and add a line containing the following path:
    C:\Program Files\boost\boost_1_35_0\lib
    
    or whatever the appropriate number is for your version.

Once you have done this, to make use of any of the Boost features, you have only to #include the appropriate header(s) in your code.

On-Line References

  1. Wikipedia's take on TR1 Wikipedia, the free encyclopedia, provides a look at Technical Report 1.
  2. Scott Meyers' take on TR1 and Boost Scott Meyers discusses TR1 and Boost.
  3. The TR1 section of the Boost site A direct link to Chapter 18. Boost.TR1.
  4. Boost The Boost home page.
  5. Wikipedia's take on C++0x Wikipedia, the free encyclopedia provides a look at what may be new in C++0x, the upcoming C++ Standard.
  6. Visual Studio 2008 Feature Pack Released Among other things, this "Feature Pack" contains an implementation of TR1.
  7. Podcasts Some informative (short) videos containing interviews with some key folks from the C++ community, including Scott Myers, Herb Sutter, and Bjarne Strousstrup himself. Look in the OnSoftware group for these names.