Why shared_ptr has an explicit constructor

前端 未结 5 865
挽巷
挽巷 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:27

    Long time lurker, and a 3rd year soft eng student here, Haphazard guess would be, to stop you from attempting to convert a 'natural' pointer to a shared_ptr, then deallocing the pointed object, without the shared_ptr knowing about the dealloc.

    (Also, reference counting problems blah blah).

提交回复
热议问题