一个函数指针名称申明typedef void* (*SFThreadFuncPtr)(void* pUser);[](void* _This) -> void*{}为什么这个lambda没办法传给这个SFThreadFuncPtr定义的变量?
typedef void* (*SFThreadFuncPtr)(void* pUser);
[](void* _This) -> void*{}
认证0级讲师
[](void _This) -> void {}[](void _This) -> void{}编码~~
The type of
lambda expression is a closure and cannot be directly assigned to a pointer type. You can use std::function to wrap the lambda expression and then call it.
lambda
std::function
#include <functional> std::function<void* (void*)> fun; fun = [](void* _This) -> void* { return NULL;}; fun(NULL);
[](void _This) -> void {}
[](void _This) -> void{}
编码~~
The type of
lambda
expression is a closure and cannot be directly assigned to a pointer type. You can usestd::function
to wrap thelambda
expression and then call it.