jeudi 26 mai 2016

Lambda seems to capture garbage

The class in question has a member foo::update(state s). foo::update is a lambda that captures all local variables by reference; in the constructor for the class it looks like update=[&](s){...}. When update() is actually called, however, all the local variables are invariably garbage. I have tried swapping out [&] for [this], and the same phenomenon happened.

Why is the lambda operating on garbage and how do I fix it?

Aucun commentaire:

Enregistrer un commentaire