hash_map question

S

Stefan Istrate

On http://www.sgi.com/tech/stl/hash_map.html it says that hash_map is
only an extension of the SGI implementation, not a part of the C++
standard. But in g++ 4.1.3 I can manage it to work using the header
<ext/hash_map> and the namespace __gnu_cxx. So, it is present in more
implementations, not just SGI. Is this a thing I can trust in? Will I
always find hash_map on all new g++ versions? Should I care about
portability or it is safe to use it?
 
I

Ian Collins

Stefan said:
On http://www.sgi.com/tech/stl/hash_map.html it says that hash_map is
only an extension of the SGI implementation, not a part of the C++
standard. But in g++ 4.1.3 I can manage it to work using the header
<ext/hash_map> and the namespace __gnu_cxx. So, it is present in more
implementations, not just SGI. Is this a thing I can trust in? Will I
always find hash_map on all new g++ versions? Should I care about
portability or it is safe to use it?

Not if you want maximum portability. hash_map will be in the next
revision of the standard.
 
J

James Kanze

Onhttp://www.sgi.com/tech/stl/hash_map.htmlit says that hash_map is
only an extension of the SGI implementation, not a part of the C++
standard. But in g++ 4.1.3 I can manage it to work using the header
<ext/hash_map> and the namespace __gnu_cxx. So, it is present in more
implementations, not just SGI. Is this a thing I can trust in? Will I
always find hash_map on all new g++ versions? Should I care about
portability or it is safe to use it?

Yes and no. I think most implementations do support some
variant of hash_map, or hashmap, sometimes in std::, and
sometimes in a separate namespace. There are subtle differences
between the implementations, however, so for maximum
portability, you'd want to wrap it in your own class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top