我正在尝试在我的bfs算法中实现unordered_set,但它给了我这个错误:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c / v1 / memory:2412:40:错误:'__compressed_pair'的多次重载实例化到同一个签名'void(_T2_param)'(又名'void(int)')_LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param _t2)^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c / v1 / __ hash_table:969:59:注意:在实例化模板类'std :: __ 1 :: __ compressed_pair>'这里请求__compressed_pair p2; ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c / v1 / unordered_set:353:13:注意:在模板类'std :: __ 1的实例化中: : hash_table,std :: __ 1 :: equal_to,std :: __ 1 :: allocator'在这里请求__table _table; ^ AICharques.cc:47:21:注意:在实例化模板类'std :: __ 1 :: unordered_set,std :: __ 1 :: equal_to,std :: __ 1 :: allocator>'这里请求unordered_set访问; ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c / v1 / memory:2410:40:注意:上一个声明在这里_LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1)

这是我的代码:

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是一个结构,包含两个整数,i和j . (在一个板中的位置) . 当我只使用一组时,错误就会消失 .