这是c++11新添加的,头文件#include <functional>
官方说明:
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.
The stored callable object is called the target of
std::function
. If a
std::function
contains no target, it is called empty. Invoking the target of an empty
std::function
results in std::bad_