News for hackers. Stuff that matters.
Re:C++: The Most Important Complexities by devnullbrain on Thursday November 16, 2023 @10:01AM (#38290357)
If an STL container lacks a method, it's a hint that 'here be dragons'. For example, random access of a std::list: it's possible, but you don't want the uninformed to be doing it without considering the consequences simply because it's easy to write.

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.
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).