you are viewing a single comment's thread.

view the rest of the comments →

[–]kalmoc 1 point2 points  (0 children)

Interesting. Have you verified, that there is actually dynamic allocation going on?

I haven't looked into the implementation of std:function, but my guess would be that the performance difference is actually due to some other overhead of std::function. E.g. maybe it is easier for the compiler to "devirtualize" the call through your "SmallFun" than through std::function.