All challenges
Code AnalysisBeginner 60s

Lambda capturing loop var by value

What does this print?
Starter code
std::vector<std::function<void()>> fs;
for (int i = 0; i < 3; ++i)
    fs.push_back([i] { std::cout << i; });
for (auto &f : fs)
    f();

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle