gpt4 book ai didi

c++ - 如何强制 MinGW 使用 tr1 命名空间?

转载 作者:太空狗 更新时间:2023-10-29 19:46:53 25 4
gpt4 key购买 nike

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

澄清:我也在用 msvc10 编译这段代码,它在两个命名空间中都支持 unordered_map,但只在一个位置。所以我想让它用两个编译器编译,尽可能少地改变。

最佳答案

包括<tr1/unordered_map>并使用 std::tr1::unordered_map<> .

编辑:

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.

要使它在两个编译器上都能编译,你可以使用类似的东西:

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

关于c++ - 如何强制 MinGW 使用 tr1 命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6263262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com