Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one include TR1?

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?

like image 484
Grumbel Avatar asked Aug 04 '09 16:08

Grumbel


2 Answers

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.

like image 171
Martin York Avatar answered Nov 20 '22 12:11

Martin York


#ifdef _WIN32
    #include <unordered_map>
    #include <memory>
#else
    #include <tr1/unordered_map>
    #include <trl/memory>
#endif
like image 14
mtd Avatar answered Nov 20 '22 13:11

mtd