I have an inner lambda that uses one of the referenced variables of the outer lambda like this:
int x=0;
auto outer=[&](){
return [&](){
x=5;
};
};
auto inner= outer();
inner();
std::cout << x;
I tried it. It worked well. However, I want to make sure that there is no dangling reference here. Is there?
Aucun commentaire:
Enregistrer un commentaire