Difference between std::remove and erase for vector?

后端 未结 8 1929
失恋的感觉
失恋的感觉 2020-12-12 18:42

I have a doubt that I would like to clarify in my head. I am aware of the different behavior for std::vector between erase and std::remove

8条回答
  •  余生分开走
    2020-12-12 19:26

    Yes, that's the gist of it. Note that erase is also supported by the other standard containers where its performance characteristics are different (e.g. list::erase is O(1)), while std::remove is container-agnostic and works with any type of forward iterator (so it works for e.g. bare arrays as well).

提交回复
热议问题