Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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
  • AIX (Power): GCC, xlC
  • Cray XT Series (AMD): GCC, Portland, Pathscale Compilers
  • IBM Blue Gene Series (Power): xlC, GCC
  • SGI Altix (Itanium): Intel compilers
  • Windows: Not really a priority, but feel free to provide useful answers.

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? Are they ubiquitous yet? Would you use them in your project?

like image 669
Todd Gamblin Avatar asked Dec 03 '22 08:12

Todd Gamblin


2 Answers

I would probably look for the boost equivelant and use that. 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. 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. 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)

like image 88
Doug T. Avatar answered Dec 04 '22 21:12

Doug T.


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

like image 27
John Leidegren Avatar answered Dec 04 '22 23:12

John Leidegren