hash_map<> and string...
george@moberg.com
george@moberg.com
Thu Nov 9 09:25:00 GMT 2000
I'm using the last snapshot release w/gcc 2.95.2 on Linux and I want to
use hash_map<> with the string type as a key. I end up having a header
that does this:
/***************************************************************
*
* Note: This file used to contain a home-grown
associative
* array class. This was changed 3/8/2000 by
GTT to
* use the Standard Library map<> class. The
reason
* it exists at all, is that hash_map<> doesn't
yet define
* a hash function for the string class.
*
**************************************************************/
#ifndef _ASSOC
#define _ASSOC
#include <hash_map>
#include <string>
//TODO: Change to hash_map<string, T> and eliminate
this file.
template <class T> class ASSOCIATION : public hash_map<string,
T>
{
public:
ASSOCIATION() { };
virtual ~ASSOCIATION() { };
};
//TODO: Oops...linux doesn't define hash<string>...duh.
__STL_TEMPLATE_NULL struct hash<string>
{
size_t operator()(const string& __s) const
{
return __stl_hash_string(__s.c_str());
}
};
#endif // _ASSOC
Any plans to define hash<string> for the final release? Anybody do this
already and it hasn't made it to a snapshot?
--
George T. Talbot
<george at moberg dot com>
More information about the Libstdc++
mailing list