Is there a way to increase the efficiency of shared_ptr by storing the reference count inside the controlled object?

前端 未结 4 2061
有刺的猬
有刺的猬 2021-01-20 19:15

This is becoming a common pattern in my code, for when I need to manage an object that needs to be noncopyable because either A. it is \"heavy\" or B. it is an operating sys

4条回答
  •  长发绾君心
    2021-01-20 20:01

    If you want to reduce the overhead of distinct memory allocations for your object and the reference counter, you could try to use make_shared. That's what its for.

提交回复
热议问题