I\'d like to use lambda functions to asynchronously call a method on a reference counted object:
void RunAsync(const std::function& f) { /* ..
Converting to a std::function
should only make a move of the lambda. If this isn't what's done, then there's arguably a bug in the implementation or specification of std::function
. In addition, in your above code, I can only see two copies of the original c
, one to create the lambda and another to create the std::function
from it. I don't see where the extra copy is coming from.