mardi 24 octobre 2017

Does = in a capture list of a lambda capture the this pointer

I currently have something like this

void foo::setup()
{
        //this->setSubTitleText("Summary");
        button("ok")->onPress = [=](Mtype*)
        {
            this->bar(this); //Why is the this pointer being recognized here?
        };

}

Does the = in a capture clause of a lambda give access to the this pointer. In my case it is ? I was under the impression to use the this pointer I would need to explicitly capture this like

        button("ok")->onPress = [=,this](Mtype*)
        {
            this->bar(this); //Why is the this pointer being recognized here?
        };

Any suggestions ?

Aucun commentaire:

Enregistrer un commentaire