Gamedev, the main loop, 16 milliseconds per frame. The profiler catches a std::vector deciding to reallocate exactly mid-boss-fight. The lead's verdict: 'heap in the hot path is a ban'. You need a vector on the stack: fixed capacity, familiar API, zero allocations.
Implement StaticVector<T, N> — a sequence container that stores up to N elements in-place, with no heap allocation. It is the building block behind small-buffer optimisations and embedded code where new is forbidden.
<typename T, std::size_t N>new, malloc, std::vector)push_back past capacity throws std::length_errorcapacity() returns N; size() tracks the live countT (test uses int and std::string)std::size_t N) let the capacity be fixed at compile time?N slots up front?A non-type template parameter like std::size_t N can size a plain member array: T data_[N];.
Keep a separate std::size_t size_ counter; push_back writes data_[size_++], pop_back does --size_.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.