Are there any “penalties” for defining a struct inside a function?
In C++11, no – there’s no penalty. I would even consider it a very good style to not pollute any “more visible” scopes with you implementation details, unless, of course, you want to reuse that functor elsewhere. However, lambdas are essentially a condensed form of this idea, and should usually be preferred if you are … Read more