Answer
std::function is a type-erased, general-purpose polymorphic wrapper that can hold any callable (lambda, function pointer, functor) matching a given signature. It's useful for storing lambdas in containers or class members where the exact closure type can't be named, at the cost of some overhead versus auto or templates.
std::function<int(int)> f = [](int x){ return x*x; };
std::vector<std::function<void()>> callbacks;Real-world example A UI framework stores button callbacks as std::function<void()> so any lambda can be registered.