I want to find point, which has the less Y coordinate (if more of such points, find the one with smallest X). When writing it with lambda:
std::min_element(begin, end, [](PointAndAngle& p1, PointAndAngle& p2) {
if (p1.first->y() < p2.first->y())
return true;
else if (p1.first->y() > p2.first->y())
return false;
else
return p1.first->x() < p2.first->x();
}
I am getting:
error C3499: a lambda that has been specified to have a void return type cannot return a value
what is the difference between:
// works
std::min_element(begin, end, [](PointAndAngle& p1, PointAndAngle& p2) {
return p1.first->y() < p2.first->y();
}
and
// does not work
std::min_element(begin, end, [](PointAndAngle& p1, PointAndAngle& p2) {
if (p1.first->y() < p2.first->y())
return true;
else
return false;
}