How to erase elements from boost::ptr_vector

前端 未结 6 1297
清歌不尽
清歌不尽 2021-01-12 13:52

So I\'m trying to get rid of my std::vector\'s by using boost::ptr_vector. Now I\'m trying to remove an element from one, and have the removed element deleted as well. The m

6条回答
  •  有刺的猬
    2021-01-12 14:36

    I think you want to call .release() on the vector instead of erase. That removes the entry and deletes the memory.

    See the section "New Functions" for details in the tutorial, or check the reference.

    Alternatively, you need to get an iterator to an element in order to call erase(), I'm ot sure an A* counts in terms of a ptr_vector.

提交回复
热议问题