Idiomatic use of std::auto_ptr or only use shared_ptr?

前端 未结 5 1533
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 03:12

Now that shared_ptr is in tr1, what do you think should happen to the use of std::auto_ptr? They both have different use cases, but all use cases of

5条回答
  •  眼角桃花
    2021-02-04 04:10

    I believe that "wrap all pointers in shared_ptr" should indeed be the default mode, and is suitable advice to give to your junior coders. However, in the special ownership cases that you mentioned, auto_ptr is indeed more appropriate and its use should be encouraged under such circumstances.

提交回复
热议问题