1. Object pointer and function pointer: this callback function parameters of the incoming object and function names, or only to global functions or static function as a function pointer is passed
2。std::function和std::bind
https://www.jianshu.com/p/f191e88dcc80
C ++ reference manual describes the function of:
Examples std :: function can store, and copying any target callable call, comprising: a function, lambda expressions, bind expression or function of other objects, and point to a member function pointer and a pointer to data members, std :: function contained in functional header file。
std :: function can hold any object can live by "()" to call, including:
- Ordinary function
- Member function
- Functor
- lambda
- std::bind
typedef std::function<void(int, const char*)> CallbackFunc;
void SubThread::setCallback(CallbackFunc cb_func1);
void MainThread::executeFunc(int a, const char* s);
sub_thread.setCallback(std::bind(&MainThread::executeFunc, this, std::placeholders::_1, std::placeholders::_2));