简体   繁体   English

hash_map无处不在?

[英]How ubiquitous is hash_map?

The hash_map and hash_set headers aren't included in the C++ standard yet, but they're available as extensions with all the compilers I've used lately. hash_maphash_set头文件尚未包含在C ++标准中,但它们可以作为我最近使用的所有编译器的扩展。

I'm wondering how much I can rely on these in real code without sacrificing portability. 我想知道在不牺牲可移植性的情况下,我可以在实际代码中依赖这些内容。 I'm working on tools projects that need to run on a host of architectures and compilers, including: 我正在研究需要在大量架构和编译器上运行的工具项目,包括:

  • Linux (x86_64, AMD/Intel): GCC, Intel, Portland Compilers Linux(x86_64,AMD / Intel): GCC,Intel,Portland Compilers
  • AIX (Power): GCC, xlC AIX(Power): GCC,xlC
  • Cray XT Series (AMD): GCC, Portland, Pathscale Compilers Cray XT系列(AMD): GCC,Portland,Pathscale Compilers
  • IBM Blue Gene Series (Power): xlC, GCC IBM Blue Gene系列(电源): xlC,GCC
  • SGI Altix (Itanium): Intel compilers SGI Altix(安腾):英特尔编译器
  • Windows: Not really a priority, but feel free to provide useful answers. Windows:不是优先事项,但随时提供有用的答案。

I realize some of these are pretty exotic, but that's not the point. 我意识到其中一些非常奇特,但这不是重点。 What are your experiences with STL extensions across multiple platforms and compilers? 您在多个平台和编译器上使用STL扩展的经历是什么? Are they ubiquitous yet? 它们无处不在吗? Would you use them in your project? 会在你的项目中使用它们吗?

I would probably look for the boost equivelant and use that. 我可能会寻找助推器equivelant并使用它。 At least they have some pressure from their users to be platform independent. 至少他们的用户有一些独立于平台的压力。 I can't imagine what would happen if you filed a bug against GCC and Intel compilers and told them to reconcile their differences on how hash_map was implemented. 我无法想象如果您提交了针对GCC和英特尔编译器的错误并告诉他们调整他们在hash_map实现方式上的差异会发生什么。 At best you would be able to get them to talk to each other. 充其量你可以让他们互相交谈。 Suppose you even acheived that, then you've only fixed how Intel and GCC compilers are different. 假设你甚至实现了这一点,那么你只修复了英特尔和GCC编译器的不同之处。 Good luck getting everyone else together and solving the problem within a few years. 祝你好运,让他人在一起,并在几年内解决问题。

At least with boost you know any differences across platforms are being worked out by one organization.. 至少通过提升你知道一个组织正在制定跨平台的任何差异。

EDIT The boost equivalent is apparently unordered set or unordered map . 编辑增强等效显然是无序的设置无序地图 (thanks Head Geek) (感谢Head Geek)

NO, you would write your own if you're a large enough organization/project. 不,如果你是一个足够大的组织/项目,你会写自己的。 That way you can tailor them to better suit your needs and address portability issues. 这样您就可以定制它们以更好地满足您的需求并解决可移植性问题。 EA did this, with their "eastl" intended to target all gaming platforms, PC, Mac, XBOX360, Wii, PS2, PS3 etc... EA做到了这一点,其“eastl”旨在针对所有游戏平台,PC,Mac,XBOX360,Wii,PS2,PS3等...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM