Boost logo

Boost :

Subject: Re: [boost] Thoughts on make_shared and shared_from_this in a constructor
From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2009-03-07 16:57:12


On Saturday 07 March 2009, Peter Dimov wrote:
> I can't think of a good way to pass this shared_ptr to the
> enable_shared_from_this base since we have no control over T.

But we do have control over T. That is, if the user wants to define a
class T which uses shared_from_this in its constructor, we can require
them to fulfill certain requirements, right? Maybe something like
providing a special constructor signature which accepts the owning
shared_ptr, plus maybe an extra tag object to insure it doesn't get
confused with other constructor overloads. Although if the T constructor
is receiving the shared_ptr directly, it wouldn't have any need to call
shared_from_this().




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk