【发布时间】:2017-06-20 05:16:01
【问题描述】:
我尝试将成员指针传递给 C++11 lambda,但没有成功
pHub是成员指针
我不断收到以下错误
error C2664: 'void Timer::start(void (__cdecl *)(Timer *),int,int)': cannot convert argument 1 from 'Scheduler::start::<lambda_292d45d0b31426827abd837d93b45bff>' to 'void (__cdecl *)(Timer *)'
我希望能够在函数内部使用pHub
pTimer = new Timer(pHub->getLoop());
pTimer->start([this](Timer *tick) {
uv_update_time(pHub->getLoop());
start_time = uv_now(pHub->getLoop());
printf("Im Tick\n");
}, 1000, 1000);
【问题讨论】:
-
只有无捕获的 lambda 可以转换为函数指针。
-
什么意思
-
你应该发布
Timer的定义,至少是相关的部分,如果你想获得正确的帮助。