I'm using MinGW 4.5.2 and I'd like to use unordered_map from the tr1 namespace, not the one from std namespace that is enabled by passing -std=c++0x. I'm sure this can be done since there are two unordered_map files, and one is in the tr1 sub-directory.
Clarification: I'm also compiling this code with msvc10 and it supports unordered_map in both namespaces but only in one locati开发者_开发技巧on. So I'd like to make it compile with both compilers with changing as least as possible.
Include <tr1/unordered_map>
and use std::tr1::unordered_map<>
.
EDIT:
I'm also compiling this code with msvc10 and it supports it in both namespaces but only in one location. So I'd like to make it compile with both compilers with changing as least as possible.
To make it compile with both compilers you can use something like:
#if defined(_MSC_VER) && _MSC_VER >= 1600
# include <unordered_map>
#else
# include <tr1/unordered_map>
#endif
Isn't this as simple as
#include <tr1/unordered_map>
精彩评论