As per the documatation(What is a lambda expression in C++11?), The return type of the lambda could be deduced in this code. I could not get the idea how it could be done?
void func4(std::vector<double>& v)
{
std::transform(v.begin(), v.end(), v.begin(),
[](double d) { return d < 0.00001 ? 0 : d; }
);
}
But,it cannot be deduced in this example, why?
void func4(std::vector<double>& v) {
std::transform(v.begin(), v.end(), v.begin(),
[](double d) {
if (d < 0.0001) {
return 0;
} else {
return d;
}
});
}