У меня есть следующий код, чтобы сделать unordered_set<Interval>
. Это прекрасно компилируется.
struct Interval {
unsigned int begin;
unsigned int end;
bool updated; //true if concat. initially false
int patternIndex; //pattern index. valid for single pattern
int proteinIndex; //protein index. for retrieving the pattern
};
struct Hash {
size_t operator()(const Interval &interval);
};
size_t Hash::operator()(const Interval &interval){
string temp = to_string(interval.begin) + to_string(interval.end) + to_string(interval.proteinIndex);
return hash<string>()(temp);
}
unordered_set<Interval, string, Hash> test;
Однако я не могу скомпилировать, когда пытаюсь вставить этот код:
for(list<Interval>::iterator i = concat.begin(); i != concat.end(); ++i){
test.insert((*i));
}
Кроме того, я не могу определить, что проблема из сообщений об ошибках.
Вот пример:
note: candidate is:
note: size_t Hash::operator()(const Interval&)
note: candidate expects 1 argument, 2 provided
Я думал, что только один аргумент...
Кто-нибудь видит проблему с моим кодом вставки? Пожалуйста, помогите, если можете - я давно искал решение.
EDIT:
Здесь новый код создания: unordered_set<Interval, Hash> test;
Тем не менее, я все еще получаю множество сообщений об ошибках. Пример:
note: candidate is:
note: size_t Hash::operator()(const Interval&) <near match>
note: no known conversion for implicit ‘this’ parameter from ‘const Hash*’ to ‘Hash*’