Why shared_ptr has an explicit constructor

前端 未结 5 875
挽巷
挽巷 2020-12-19 17:19

I was wondering why shared_ptr doesn\'t have an implicit constructor. The fact it doesn\'t is alluded to here: Getting a boost::shared_ptr for this

(I f

5条回答
  •  我在风中等你
    2020-12-19 17:37

    In this case, the shared_ptr would attempt to free your stack allocated int. You wouldn't want that, so the explicit constructor is there to make you think about it.

提交回复
热议问题