Custom (pool) allocator with boost shared_ptr

前端 未结 3 1084
灰色年华
灰色年华 2021-01-31 09:20

I want objects managed by a shared_ptr to be allocated from a pool, say Boost\'s Pool interface, how can this be achieved?

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 09:59

    These are almost orthogonal concerns. shared_ptr plays no part in allocation of objects.

    Where it is concerned is in the deletion of memory no longer referenced. If you have allocated from anything other than the default heap you'll need to provide a custom deleter

提交回复
热议问题