vendredi 1 juillet 2016

Using `this->` in a lambda that captures `this`

There are several similar questions out there, but I can't find a definitive answer to this specific point.

Is it completely equivalent to use or not use this-> when calling a method or a member variable within a lambda that captures this, or there is some nuanced difference?

class C {

    int var;
    void foo();

    void fool() {

       auto myLambda = [this] () {
           //
           this->var = 1;
           this->foo();
           // 100% equivalent to?
           var = 1;
           foo();
       }
    }
}

Aucun commentaire:

Enregistrer un commentaire