
7 Mar
2009
7 Mar
'09
9:57 p.m.
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().