What is boost's shared_ptr(shared_ptr const & r, T * p) used for?

后端 未结 6 1222
孤街浪徒
孤街浪徒 2021-02-01 04:28

boost::shared_ptr has an unusual constructor

template shared_ptr(shared_ptr const & r, T * p);

and I a

6条回答
  •  礼貌的吻别
    2021-02-01 04:39

    You might have a pointer to some driver or a lower level api's data structure that may allocate additional data by its lower level api or other means. In this case it might be interesting to increase the use_count but return the additional data if the first pointer owns the other data pointers.

提交回复
热议问题