c++ lambda表达式的问题
PHP中文网
PHP中文网 2017-04-17 15:06:19
0
2
539

一个函数指针名称申明
typedef void* (*SFThreadFuncPtr)(void* pUser);
[](void* _This) -> void*{}
为什么这个lambda没办法传给这个SFThreadFuncPtr定义的变量?

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
Ty80

[](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.

#include <functional>

std::function<void* (void*)> fun;

fun = [](void* _This) -> void* { return NULL;};

fun(NULL);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template