Re:C++: The Most Important Complexities
by quietbritishjim on Thursday November 16, 2023 @10:41AM
(#38290900)
You're arguing that there aren't STL methods for doing inefficient things.
But there 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, but 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).
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:
to get pop.