Also, it's advisable not to store lambdas in std::function objects.
As you saying, don't store lambdas in std::function unless you need to (i.e. passing a lambda into a function that takes std::function as a parameter), or are you saying never use std::function to store a lambda?
I store lambdas in std::function all the time. Ofcourse if the lambda doesn't need to be stored for later calling, I just use auto, but since I still use std::function alot, I'd like to know if there's a problem with that that I'm not aware of.
Are you saying that std::function's member vars takes a few extra bytes to hold the object, which requires a separate allocation (definitely worth pointing out), or are you warning about something more dangerous?
You are right I didn't put that correctly. It's totally fine storing them in std::function objects if there is no alternative to the task at hand.
The problem with std::function is that its the same size for every kind of function it could store, so it does extra allocations if its memory is not enough to store bookkeeping information about the lambda.
Imagine having a game with tons of those small allocations each frame because you just define and store some lambdas. It could hinder performance.