如何强制MinGW使用tr1命名空间? [英] How can I force MinGW to use tr1 namespace?

查看:106
本文介绍了如何强制MinGW使用tr1命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MinGW 4.5.2,我想从tr1命名空间使用unordered_map,而不是通过传递-std = c ++ 0x启用的std命名空间。我确信这可以做,因为有两个unordered_map文件,一个在tr1子目录。

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.

澄清:
我也使用msvc10编译此代码,它在两个命名空间中支持unordered_map,但只能在一个位置。

Clarification: I'm also compiling this code with msvc10 and it supports unordered_map 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.

推荐答案

包含< tr1 / unordered_map> 并使用 std :: tr1 :: unordered_map<>

编辑:


我也用msvc10编译此代码,它支持它在两个命名空间,但只在一个位置。所以我想让编译器与两个编译器尽可能少地更改。

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

这篇关于如何强制MinGW使用tr1命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆