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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 19:08:30  来源:igfitidea点击:

Is hash_map part of the STL?

c++stlhashmap

提问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.

STLhash_map,但 C++ 标准库没有

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_mapas a compiler-specific extension), place it in the stdnamespace, which is not only highly misleading, but also illegal per the standard. *sigh*

MSVC++ 和 GCC(hash_map作为特定于编译器的扩展实现)都将它放在stdnamespace 中,这不仅具有高度误导性,而且根据标准也是非法的,这也是一个巨大的耻辱。*叹*

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_mapis 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 container unordered_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_mappart of Standard C++? No, it isn't. unordered_mapwill 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.

Yes, hash_mapis part of the STL. However, it is notpart of C++03's standard library.

是的hash_mapSTL 的一部分。但是,它不是C++03 标准库的一部分。

回答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 标准的一部分。