我已经用过typedef
typedef std::pair<int, int> coords;
typedef std::pair<float, coords> fcoords;
然后创建此数据类型的 vector
std::vector<fcoords> openList;
因此,当我尝试向 vector 添加元素时,为什么必须使用make_pair进行处理
int i = _start.first;
int j = _start.second;
openList.push_back(std::make_pair(0.0, std::make_pair(i, j)));
为什么不能仅通过添加值来做到这一点?
openList.push_back(0.0f, (i, j));
最佳答案
您可以使用:
openList.push_back({0.0f, {i, j}});
关于c++ - 为什么我必须使用std::make_pair?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59254593/