As with most things it boils down to scope...<p>&#x27;Class template std::function is a general-purpose polymorphic function wrapper. Instances of std::function can store, copy, and invoke any Callable target -- functions, lambda expressions, bind expressions, or other function objects, as well as pointers to member functions and pointers to data members.&#x27;<p>This clearly does more than the OPs code and therefore has more complexity.