【发布时间】:2017-10-24 22:12:30
【问题描述】:
我目前有这样的东西
void foo::setup()
{
//this->setSubTitleText("Summary");
button("ok")->onPress = [=](Mtype*)
{
this->bar(this); //Why is the this pointer being recognized here?
};
}
lambda 的捕获子句中的= 是否允许访问this 指针。在我的情况下是?我的印象是使用 this 指针,我需要像
button("ok")->onPress = [=,this](Mtype*)
{
this->bar(this); //Why is the this pointer being recognized here?
};
有什么建议吗?
【问题讨论】:
-
是的....确实如此。
-
@ChrisDrew 我认为与 = 它仅按值捕获封闭范围中的所有变量。所以这意味着这也包括在内?