Why doesn’t std::vector::push_front() exist?

You don’t want to push_front on a vector ever. Adding an element to the front means moving every single other element in the vector one element back: O(n) copying. Terrible performance.

Leave a Comment