Getting Started with C++ TR1 Libraries
What is C++ TR1?
What exactly is C++ TR1? It is the first Technical Report on C++ Library Extensions as accepted by C++ standards committee and these library extensions will be available in the next official C++ standard to be released - C++0x. All the libraries that are a part of C++ TR1 will be included (hopefully) by the compilers once the next C++ standard is finalised and released. Mathew Austern nicely introduces C++ TR1 on the Dr. Dobbs Journal website:
The C++ Standard Library is a large and successful project. The specification of the library is about 370 pages in length[..] If a C++ program was written within the last five years, it's standard fare for it to use std::string, STL containers and algorithms, or IOStreams.
But if we look at it a little differently, the Standard Library doesn't seem so large after all. The Perl, Python, and Java standard libraries include facilities for parsing XML, performing regular expression searches, manipulating image files, and sending data over the network. From that perspective, the C++ Standard Library looks like it's only the beginning.[...] The question isn't whether we need a more comprehensive library, but how we get one. Historically, members of the Standards committee came up with two answers: Boost Libraries and C++ TR1.
The draft version of the official document describing the extensions to the C++ standard library is available for download from open-std.org website.
Does My Compiler Support C++ TR1?
But if you would like to immediately start playing with these libraries in your C++ programs without having to wait for the next C++ standard to be finalised and released, you have two options to do so.
If you are a Windows user, then you can either search for a the binary package of GCC 4.0 or later(only DJGPP seems to support the GCC 4 version; MinGW and Cygwin use older versions) or you can try to build such a version manually from the latest GCC sources. Scott Meyers describes his experience at manually building GCC on his machine and an adapted version of the same is published by MinGW website:
Testing C++ TR1 Support on Your GCC System
Fire up your favourite programming editor and enter the following code in it:
If the above program compiles on your system without any complains from the compiler, then you have got the right version of gcc and libstdc++ installed on your system. You can start scanning through the TR1 libraries and testing how many of them are supported on your system. Below is just another example to test:
You can find more example TR1 code snippets in Austern's article or on the Boost website.
New Boost Subset Package For C++ TR1
Boost has announced a new package couple of weeks back containing the subset of Boost Libraries by including only those libraries that have been accepted in C++ TR1. It is in alpha stage right now and currently going through evaluation by the community members. Those who are interested in such a library package can download it from the sourceforge.net website and give it a try. The procedure to download, install, and use the library is summarised below.
According to the (one month old) mailing list announcement, the subset includes:
For more documentation on these libraries, refer to the official TR1 document and Boost website. I will follow up with step-by-step procedure to download and install Boost C++ TR1 subset library.