Search code examples
c++c++11path-finding

Why do I have to use std::make_pair?


I have already used typedef

typedef std::pair<int, int> coords;
typedef std::pair<float, coords> fcoords;

and then created a vector of this data type

std::vector<fcoords> openList;

so when I try to add an element to the vector, why do I have to do it with make_pair

int i = _start.first;
int j = _start.second;
openList.push_back(std::make_pair(0.0, std::make_pair(i, j)));

Why can I not do it by just adding the values in?

openList.push_back(0.0f, (i, j));

Solution

  • You might use:

    openList.push_back({0.0f, {i, j}});