views:

509

answers:

3

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?

+5  A: 

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

John Leidegren
+8  A: 

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)

Doug T.
The "Boost equivalent," if I'm not mistaken, is `unordered_map` and `unordered_set`. You'll need a pretty recent version of Boost though.
Head Geek
It's going into the next standard that way, I believe.
David Thornley
A: 

I can recommend STLport, http://www.stlport.org/. It supports all GCC platforms, xlC for AIX, some SGI. Not to mention Windows. I use it myself and have no complaints.

Jonas Byström