Code Room
Code reviewMediumcr-g374
Subject Iterator invalidationLevel Mid–Senior~18 minCommon in Code quality & review interviewsIndustries Software development, Computer games

Question

Review this C++ code that removes expired sessions from a vector.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewcpp
for (auto it = sessions.begin(); it != sessions.end(); ++it) {    if (it->expired()) {        sessions.erase(it);   // drop this one    }}
Run or narrate your approach, then ask the coach.