Can I call `delete` on a vector of pointers in C++ via for_each ?

后端 未结 7 1540
醉梦人生
醉梦人生 2021-01-14 08:32

Suppose I have a std::vector objs (for performance reasons I have pointers not actual Objs).

I populate it with obj.push

相关标签:
7条回答
  • 2021-01-14 09:30

    Instead of trying to solve the deletion problem, you can make it go away completely by storing shared_ptrs in the vector, or by using boost's ptr_vector (see http://www.boost.org/doc/libs/1_39_0/libs/ptr_container/doc/tutorial.html).

    0 讨论(0)
提交回复
热议问题