best practice when returning smart pointers

前端 未结 9 1450
一生所求
一生所求 2020-12-24 11:56

What is the best practice when returning a smart pointer, for example a boost::shared_ptr? Should I by standard return the smart pointer, or the underlying raw pointer? I co

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 12:28

    I wouldn't put raw pointers in vectors.

    In case they use auto_ptr or boost::scoped_ptr, they can't use (or return) anything but raw pointers. That could explain their way of coding, i guess.

提交回复
热议问题