C++11 C++;标准不提供此类型的哈希。

C++11 C++;标准不提供此类型的哈希。,c++11,unordered-map,C++11,Unordered Map,我尝试为无序_映射的网格实现一个*算法,我有自己的优先级队列(whitch)可以很好地工作。问题是当我运行程序时,我得到这个错误:C++标准不提供这种类型的哈希。 A*可以用其他结构实现吗? 或者我该如何解决这个问题 int main() { std::ifstream file("Labirint.txt"); char **labirint; int nr_linii, nr_coloane; file >

我尝试为无序_映射的网格实现一个*算法,我有自己的优先级队列(whitch)可以很好地工作。问题是当我运行程序时,我得到这个错误:C++标准不提供这种类型的哈希。 A*可以用其他结构实现吗? 或者我该如何解决这个问题

    int main()
    {
        std::ifstream file("Labirint.txt");
        char **labirint;
        int nr_linii, nr_coloane;
        file >> nr_linii >> nr_coloane;
        locatie soricel;
        locatie branza;
        file >> soricel.x >> soricel.y;
        file >> branza.x >> branza.y;

        int deplasare_linie[] = { 0,0,-1,1 };
        int deplasare_coloana[] = { -1,1,0,0 };

        labirint = new char*[nr_linii];
        for (int i = 0; i < nr_linii; ++i)
            labirint[i] = new char[nr_coloane];

        for (int i = 0; i < nr_linii; i++)
            for (int j = 0; j < nr_coloane; ++j)
                file >> labirint[i][j];

        square_nod start,goal;
        start.pozitie = soricel;
        start.prioritate = 0;
        goal.pozitie = branza;

        PriorityQueue frontier;
        frontier.Insert(start);

        std::unordered_map<square_nod, int> came_from;
        std::unordered_map<square_nod, int> cost_so_far;

        cost_so_far.insert(std::make_pair(start, 0));

        while (!frontier.isEmpty())
        {
            square_nod current = frontier.minElement();
            frontier.extractMin();
            if (current == goal)
            {
                break;
            }

            for (int i = 0; i < 4; i++)
            {
                square_nod next;
                next.pozitie.x = current.pozitie.x + deplasare_linie[i];
                next.pozitie.y = current.pozitie.y + deplasare_coloana[i];
                int new_cost = cost_so_far[current] + 1;

                auto gasit = cost_so_far.find(next);
                if (gasit == cost_so_far.end() || new_cost < cost_so_far[next])
                {
                    cost_so_far[next] = new_cost;
                    int priority = new_cost + city_block_distance(goal, next);
                    next.prioritate = priority;
                    frontier.Insert(next);
                    came_from[next] = current.prioritate;
                }
            }
        }
    }
intmain()
{
std::ifstream文件(“Labirint.txt”);
焦炉;
里尼街、路环街;
文件>>天然林>>天然路环线;
索里塞尔酒店;
布朗扎;
文件>>soricel.x>>soricel.y;
文件>>branza.x>>branza.y;
int deplasare_linie[]={0,0,-1,1};
int deplasare_coloana[]={-1,1,0,0};
labirint=新字符*[nr_linii];
对于(int i=0;i>实验室[i][j];
开始,目标;
start.pozitie=soricel;
start.prioritate=0;
goal.pozitie=branza;
优先队列边界;
边界。插入(开始);
std::无序的地图来自;
std::无序映射到目前为止的成本;
插入(std::make_pair(start,0));
而(!frontier.isEmpty())
{
方形节点电流=frontier.minElement();
frontier.min();
如果(当前==目标)
{
打破
}
对于(int i=0;i<4;i++)
{
下一步要点头;
next.pozitie.x=current.pozitie.x+deplasare_-linie[i];
next.pozitie.y=current.pozitie.y+deplasare_coloana[i];
int new_cost=迄今为止的成本[当前]+1;
auto-gasit=到目前为止的成本。查找(下一步);
如果(gasit==cost_so_far.end()| | new_cost
我想你指的是类型
方头
,你还没有列出它的定义。您需要为您的类添加一个。 借用

名称空间std{
模板结构哈希
{
大小运算符()(常量Foo&x)常量
{
/*在这里输入您的代码,例如“return hash()(x.value);”*/
}
};
}
namespace std {
  template <> struct hash<Foo>
  {
    size_t operator()(const Foo & x) const
    {
      /* your code here, e.g. "return hash<int>()(x.value);" */
    }
  };
}