How does one include TR1?

Grumbel picture Grumbel · Aug 4, 2009 · Viewed 32.1k times · Source

Different compilers seem to have different ideas about TR1. G++ only seems to accept includes of the type:

#include <tr1/unordered_map>
#include <tr1/memory>
...

While Microsofts compiler only accept:

#include <unordered_map>
#include <memory>
...

As for as I understand TR1, the Microsoft way is the correct one.

Is there a way to get G++ to accept the second version? How does one in general handle TR1 in a portable way?

Answer

Martin York picture Martin York · Aug 4, 2009

Install boost on your machine.
Add the following directory to your search path.

<Boost Install Directory>/boost/tr1/tr1

see here boost tr1 for details

Now when you include <memory> you get the tr1 version of memory that has std::tr1::shared_ptr and then it includes the platform specific version of <memory> to get all the normal goodies.