std::vector<double> cMinDist;
for (int i = 0; i < mc_4.size(); i++)
{
std::vector<double> temp;
for (int j = 0; j < mc_4.size(); j++)
{
if (j == i)
{
continue;
}
temp.push_back( sqrt(pow(mc_4[i].x - mc_4[j].x,2) + pow(mc_4[i].y - mc_4[j].y,2)));
}
std::vector<double>::iterator result =std::min_element(std::begin(temp),std::end(temp));
cMinDist[i] =result; //error is here
}
well get this error
11 IntelliSense: no suitable conversion function from "std::_Vector_iterator<std::_Vector_val<std::_Simple_types<double>>>" to "double" exists
how can I extract the result from the iterator, not the index number just the result?
Do I really need to do something like:
int index = std::distance(std::begin(temp), result);
cMinDist[i] =temp[index];
or is there a shorter way?
Aucun commentaire:
Enregistrer un commentaire