Smart pointers in container like std::vector?

后端 未结 5 2005
你的背包
你的背包 2020-12-05 11:02

I am learning about smart pointers (std::auto_ptr) and just read here and here that smart pointers (std::auto_ptr) should not be put in containers

5条回答
  •  死守一世寂寞
    2020-12-05 11:40

    The problem you are referring to concerns auto_ptr since it moves ownership on copy. shared_ptr and unique_ptr work just fine with containers.

提交回复
热议问题