Я пытаюсь реализовать словари в C ++, но когда я определяю специализацию класса ha sh, я получаю ошибку:
error: 'hash' is not a class template
error: template argument required for 'class hash'
Вот код
template <class T>
class hash{
public:
size_t operator()(const T the_key) const;
};
/* a specialization with type string */
template<>
class hash<string>
{
public:
size_t operator()(const string the_key) const {
unsigned long hash_value = 0;
int length = (int) the_key.length();
for (int i=0; i<length; i++)
hash_value = 5 * hash_value + the_key.at(i);
return size_t(hash_value);
}
};
В чем может быть проблема?