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?
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.
#ifdef _WIN32
#include <unordered_map>
#include <memory>
#else
#include <tr1/unordered_map>
#include <trl/memory>
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With