If I have code like this:
int executeTypeErased(const std::function<int()>& f)
{
return f();
}
void test()
{
executeTypeErased([] {
return 42;
});
}
When I call test(), am I guaranteed that no heap allocations occur due to the std::function? I know that I am guaranteed that no heap allocations occur if I wrap this in a std::reference_wrapper, but I'm less certain with an undecorated lambda as an argument, promoted to std::function.
Aucun commentaire:
Enregistrer un commentaire