Why there is no pop_front method in C++ std::vector?

前端 未结 6 1821
醉话见心
醉话见心 2020-12-15 02:27

Why there is no pop_front method in C++ std::vector?

6条回答
  •  一整个雨季
    2020-12-15 03:12

    Because a std::vector has no particular feature regarding inserting elements at the front, unlike some other containers. The functionality provided by each container makes sense for that container.

    You probably should be using a std::deque, which is explicitly good at inserting at the front and back.

    Check this diagram out.

提交回复
热议问题