2008/5/16 Noah Roberts <roberts.noah@gmail.com>:
I don't like this idea.  You are creating a dependency on the fact that
the called function will NOT keep a copy - or you are insisting that the
object in question implement the shared_from_this model.  If you later
decide that it would be prudent for the function or object in question
to create or pass a kept copy of this object then you'll have to change
the signature of the function and then each and every call to it (to
remove get() calls).

If this were Java, I might agree.

Given your assumption, I don't see how you can pass pointers to stack variables, pointers to member variables, pointers to objects in STL containers, etc., to any function, because it is not possible for those functions to know, let alone change, the lifetime of those objects.

Do you really allocate every single variable in your program on the heap and store it in a shared_ptr, just in case?

Regards,
--
 Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404