Lambda to std::function conversion performance

前端 未结 2 1409
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 06:26

I\'d like to use lambda functions to asynchronously call a method on a reference counted object:

void RunAsync(const std::function& f) { /* ..         


        
2条回答
  •  独厮守ぢ
    2021-01-21 06:47

    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.

提交回复
热议问题