This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
hash_map<> and string...
- To: libstdc++ at sources dot redhat dot com
- Subject: hash_map<> and string...
- From: george at moberg dot com
- Date: Thu, 09 Nov 2000 12:25:35 -0500
- Organization: Moberg Research, Inc.
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>