How to force MinGW to use the tr1 namespace?

I am using MinGW 4.5.2, and I would like to use unordered_map from the tr1 namespace, and not from the std namespace, which is enabled by passing -std = C ++ 0x. I am sure that this can be done since there are two unordered_map files, and one in the tr1 subdirectory.

Explanation: I also compile this code with msvc10 and supports unordered_map in both namespaces, but only in one place. Therefore, I would like to compile both compilers with minimal change.

+3
source share
2 answers

Turn on <tr1/unordered_map>and use std::tr1::unordered_map<>.

EDIT:

msvc10 , . .

, - :

#if defined(_MSC_VER) && _MSC_VER >= 1600
# include <unordered_map>
#else
# include <tr1/unordered_map>
#endif
+7

,

#include <tr1/unordered_map>
+5

All Articles