I'm trying to implement an unordered_set in my bfs algorithm, but it gives me this errors:
/Applications/http://ift.tt/2gPD0lg: error: multiple overloads of '__compressed_pair' instantiate to the same signature 'void (_T2_param)' (aka 'void (int)') _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2) ^ /Applications/http://ift.tt/2h23NxO: note: in instantiation of template class 'std::__1::__compressed_pair >' requested here __compressed_pair __p2_; ^ /Applications/http://ift.tt/2gPB4JF: note: in instantiation of template class 'std::__1::__hash_table, std::__1::equal_to, std::__1::allocator
' requested here __table __table_; ^ AICharques.cc:47:21: note: in instantiation of template class 'std::__1::unordered_set, std::__1::equal_to, std::__1::allocator >' requested here unordered_set visited; ^ /Applications/http://ift.tt/2h21VFf: note: previous declaration is here _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1)
And this is my code:
void radar_bfs(Pos actualPos){
queue<Pos> frontier;
frontier.push(actualPos);
unordered_set<Pos> visited;
visited.insert(actualPos);
while(!frontier.empty()){
auto current = frontier.front();
frontier.pop();
for(auto next : neighbors(current)) {
if(not visited.count(next)){
frontier.push(next);
visited.insert(next);
}
}
}
}
Pos is a struct that contains two ints, i and j.(position in a board). When i use just a set instead, the errors disappear.
Aucun commentaire:
Enregistrer un commentaire