vendredi 22 novembre 2019

C++ lambda - capture static member variable

I have a lambda function inside a static class method, like so:

void
MyClass::foo() {
  auto my_lambda = [](int arg) {
    // do stuff
  }
}

Where foo is a static method of MyClass. Now, inside my_lambda I want to reference another static method bar of MyClass. How can I do this? I've seen this question but it seems like this only works for non static methods, since static methods cannot reference this?

Aucun commentaire:

Enregistrer un commentaire