When a function takes an argument by value, it can usually modify it. However, this does not seem to be the case with lambdas. Why?
int main(){ int x = 0; auto lambda = [x] { x = 1; }; // error: assignment of read-only variable ‘x’ return 0;}
Aucun commentaire:
Enregistrer un commentaire