Subject: [boost] [smart ptr] [shared] suggestion: single pointer in object returned from make_shared
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2012-12-08 23:06:56
Dear Smart Ptr maintainer(s),
I recently learned that boost::make_shared allocates the space for the
pointee and the reference counter in one go. It makes a lot of sense,
and I might have suggested it if it wasn't already the case.
Now I'm assuming that a shared_ptr stores two raw pointers internally,
one to the pointee and one to the counter. I guess that would be
necessary in the "normal" case where the pointee and the counter are
Now in the case where the shared_ptr is created by make_shared,
ideally you'd need to store only one raw pointer because pointee and
counter reside in the same memory object. That would be the finishing
touch to a nonintrusive smart pointer that really performs like an
intrusive one. To me such a thing seems highly desirable.
I realise this would require a new implementation of the shared
pointer. Could this somehow be made to cooperate or at least coexist
with the old shared_pointer? Would it perhaps even be an option to
deprecate the old shared_pointer in order to entirely replace it by
the new version in the future?
I'll be most interested to read your comments on this idea.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk