All challenges
Multiple ChoiceBeginner 45s

vector reserve and pointer stability

You hold a `T*` into a `std::vector<T>` and then call `v.push_back` within capacity (no reallocation). The pointer is:
Options
  1. 1Always invalidated by any push_back, because the vector may reallocate even when capacity is not exceeded.
  2. 2Still valid; pointers only invalidate on reallocation (or erase/pop at/before the element).
  3. 3Invalidated only if T is a trivial type, since trivial types are relocated bytewise during a push_back.
  4. 4Invalidated because push_back copies the whole buffer to a new backing store regardless of the capacity.

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