has a hash_map template.
for all the simple types hash_map<Key,Data> works because
Code:
namespace std
{
template<typename T>
struct hash
{
size_t operator(const T&t) { }
};
};
If you want to write your own key type, you can:
Code:
struct MyKey
{
int x;
int y;
};
namespace std
{
template<>
struct hash<MyKey>
{
size_t operator()(const MyKey &mk) { return x<<16 + y; }
};
};
I have a template class thus:
Code:
template<typename T>
class TKey
{
size_t hash() { return // hashy number }
.
.
.
};
that will implicitly specialize any specialization of the generic TKey template.
The inner code should be very simple:
Code:
template<>
hash<KeyType>
{
size_t operator()(const KeyType &k) { return k.hash(); }
};
kind of template mechanism that allows me to specify that this should be
a generic template that can be specialized against a particular specialization
of a TKey.
