please, can any one explain me, how conditionalVariable will be stored in this case, to be used while check_calls_on_current_floor calling outside the condition block?
std::function<bool()> check_calls_on_current_floor;
if (/*Some condition*/)
{
const int conditionalVariable = /*some value*/;
check_calls_on_current_floor = [&](){
return conditionalVariable == 10; };
}
check_calls_on_current_floor();
It seems like in this case we, can access this variable outside the condition block, in case we got lambda from there.