shared_from_this from constructor

5 Dec
2007
5 Dec
'07
9:06 p.m.
Is there a way to call shared_from_this() from a constructor? It seems like a bad idea. Since the object is still being created, it would be difficult for anything to have a shared_ptr to it. And that violates a documented precondition of shared_from_this(): "There must exist at least one shared_ptr instance p that owns t." If it's not possible or just a bad idea, how about a note in the documentation at: http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html to say something like: "Calling shared_from_this from a constructor will not work, since there is no shared_pointer which owns the object."? -dan
6290
Age (days ago)
6290
Last active (days ago)
0 comments
1 participants
participants (1)
-
Daniel P Furlani