by devnullbrain · 3y ago · 0 comments
What do you do about the memory allocated for the first element? That's a decision for the programmer to think about, not for the standard to enforce. A std::deque may deallocate.
Additionally, you can just do:
std::stack<T, std::vector<T>>
to get pop.But the parent took that as a given. Their comment translates as, "why doesn't the STL allow efficient removal at the front of a vector" (which would be possible in principle, e.g. python bytearray is similar but supports it). Part of the answer is that it would need an extra internal data member.
BTW the pop on std::stack refers to the back so doesn't help with pop_front (and vector already supports pop_back).