[英]Using unordered_map of C++0x
I am using an unordered_map
which is included as: #include <unordered_map>
and the program is compiled as follows: g++ Test.cc -std=gnu++0x -o test
Am I using the unordered_map
of TR1 or that of C++0x. 我正在使用一个
unordered_map
,它包含在: #include <unordered_map>
,程序编译如下: g++ Test.cc -std=gnu++0x -o test
我使用的是TR1的unordered_map
还是C ++的unordered_map
0X。 Or is it both the same? 还是两者都一样?
I believe gcc puts their TR1 headers in <tr1/unordered_map>
, so you should be getting the C++11 version. 我相信gcc将他们的TR1标题放在
<tr1/unordered_map>
,所以你应该得到C ++ 11版本。 But they are very similar. 但它们非常相似。
GCC has tr1 headers in tr1 subdirectory. GCC在tr1子目录中有tr1头。 Plus there is the tr1 namespace.
另外还有tr1命名空间。
#include <tr1/unordered_map>
...
std::tr1::unordered_map<...>(...);
So unless you specifically did these things or did a similar "using" you've got the std ones. 因此,除非你专门做了这些事情或做了类似的“使用”,否则你会得到标准的。
The implementations are split but they are rather similar. 实现是分开的,但它们非常相似。 There were just enough differences (initializer_list, comparison ops) to make maintenance of one file with all the conditionals and macros a pain.
只有足够的差异(initializer_list,比较操作)来维护一个文件,所有条件和宏都很痛苦。
This depends very much on the particular compiler version. 这在很大程度上取决于特定的编译器版本。 For instance, GCC 4.4 basically just had some macro switches for your
-std=c++0x
option to do the namespace labelling appropriately, but would always end up pulling the actual code from tr1_impl/unordered_map
, while GCC 4.6 has two entirely separate implementations, one in tr1/unordered_map.h
and one in bits/unordered_map.h
-- and the respective base class implementations in .../hashtable.h
do in fact differ; 例如,GCC 4.4基本上只有一些宏开关用于
-std=c++0x
选项以适当地进行命名空间标记,但总是最终从tr1_impl/unordered_map
提取实际代码,而GCC 4.6有两个完全独立的实现,一个在tr1/unordered_map.h
,一个在bits/unordered_map.h
- 并且.../hashtable.h
相应的基类实现确实不同; the C++0x version has std::forward
s everywhere etc. C ++ 0x版本在任何地方都有
std::forward
s等。
Short answer: It depends. 简答:这取决于。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.