を作成する次のコードがあります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
私は1つの引数しか提供していないと思っていました...
挿入コードの問題は何ですか?
新しいインスタンス化コードは次のとおりです。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*’