mercredi 29 août 2018

Can assigning a name to a lambda impact performance?

What is the difference in terms of performance, if any, between using a lambda directly and defining a named lambda and then passing it as an argument?

For example this:

std::sort(v.begin(), v.end(), [](int a, int b) { return a > b; });

versus this:

auto a_greater_than_b = [](int a, int b) { return a > b; };
std::sort(v.begin(), v.end(), a_greater_than_b);

Aucun commentaire:

Enregistrer un commentaire