C++ hash_map 是 STL 的一部分吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5908581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is hash_map part of the STL?
提问by Jake
Quick question...Is hash_map part of the STL?
快速提问... hash_map 是 STL 的一部分吗?
回答by Lightness Races in Orbit
The STLhas hash_map
, but the C++ Standard Library does not.
Due to a common misconception, you may think of the C++ Standard Library as "the STL", or of parts of your toolchain's implementation of the C++ Standard Library as "an STL implementation".
由于一个常见的误解,您可能将 C++ 标准库视为“STL”,或者将 C++ 标准库的工具链实现的一部分视为“STL 实现”。
It is not.
它不是。
It is also a great shame that both MSVC++ and GCC (which implement hash_map
as a compiler-specific extension), place it in the std
namespace, which is not only highly misleading, but also illegal per the standard. *sigh*
MSVC++ 和 GCC(hash_map
作为特定于编译器的扩展实现)都将它放在std
namespace 中,这不仅具有高度误导性,而且根据标准也是非法的,这也是一个巨大的耻辱。*叹*
C++11 has introduced std::unordered_map
, which is not dissimilar.
C++11 引入了std::unordered_map
,这并没有什么不同。
回答by razlebe
Quoting Wikipedia (emphasis added):
引用维基百科(强调):
From the STLpage:
从STL页面:
The Standard Template Library (STL) is a software library partiallyincluded in the C++ Standard Library.
标准模板库 (STL) 是部分包含在 C++ 标准库中的软件库。
...and then from the hash_mappage
...然后从hash_map页面
In the C++ programming language,
hash_map
is the name of a hashed associative container in the Standard Template Library. It is provided by several implementors, such as the GNU C++ compiler and Microsoft's Visual C++. It is not part of the C++ Standard Library, but the C++ Technical Report 1 contains the very similar containerunordered_map
, which will be included in the upcoming C++0x standard.
在 C++ 编程语言中,
hash_map
是标准模板库中散列关联容器的名称。它由多个实现者提供,例如 GNU C++ 编译器和 Microsoft 的 Visual C++。它不是 C++ 标准库的一部分,但 C++ 技术报告 1 包含非常相似的容器unordered_map
,它将包含在即将发布的 C++0x 标准中。
So in short,
所以简而言之,
- YESit's part of the STL.
- But it IS NOTpart of the standard library.
- But it is supported by several very popular implementations.
- 是的,它是 STL 的一部分。
- 但它不是标准库的一部分。
- 但是它得到了几个非常流行的实现的支持。
回答by razlebe
The problem is that there is no agreed upon meaning for the term STL. Is hash_map
part of Standard C++? No, it isn't. unordered_map
will be part of the new C++ standard, however, and is a map implemented using hashing.
问题在于术语STL没有达成一致的含义。是hash_map
标准 C++ 的一部分吗?不,不是。unordered_map
但是,将成为新 C++ 标准的一部分,并且是使用散列实现的映射。
回答by Alexandre C.
回答by holybiner
hash_map is a part of STL, but not a part of Standard C++(C++11). And there is a similar implementation of hash_map named "std::unordered_map" in standard C++: http://www.cplusplus.com/reference/unordered_map/unordered_map/
hash_map 是 STL 的一部分,但不是标准 C++(C++11) 的一部分。在标准 C++ 中有一个类似的名为“std::unordered_map”的 hash_map 实现:http: //www.cplusplus.com/reference/unordered_map/unordered_map/
Currently, GNU C++ and MSVC++ have implemented hash_map for compiler extension, as well as Boost. Meanwhile, SGI has its own implementation for hash_map. You can refer to http://www.sgi.com/tech/stl/hash_map.htmlfor details.
目前,GNU C++ 和 MSVC++ 已经为编译器扩展以及 Boost 实现了 hash_map。同时,SGI 有自己的 hash_map 实现。详情可参考http://www.sgi.com/tech/stl/hash_map.html。
回答by Raghuram
No...Hash_map is not part of the STL standard.
不...Hash_map 不是 STL 标准的一部分。