On Fri, 3 Oct 2003 19:05:07 +0200 (Romance Daylight Time) Vadim Zeitlin <[EMAIL PROTECTED]> wrote:
> On Fri, 3 Oct 2003 18:53:08 +0200 (CEST) Robert Vazan <[EMAIL PROTECTED]> wrote: > > RV> On Fri, 3 Oct 2003 17:21:07 +0200 (Romance Daylight Time) Vadim Zeitlin > RV> <[EMAIL PROTECTED]> wrote: > RV> > RV> > 1. return raw pointer (no problem here as long as it's assigned to > RV> > shared_ptr in the caller, but, unlike when returning the object, > RV> > you can't ensure this -- still, in practice, I don't see any problems > RV> > with this, do you?) > RV> > RV> You cannot return locals this way. If the Profile object is constructed on > RV> demand as local variable, the function will return invalid pointer. > RV> > RV> > 2. return const shared_ptr reference: this, of course, supposes that all > RV> > pointers are stored as shared_ptrs but this is the goal anyhow > RV> > RV> Same problem as above. > > Yes, as I said this only works if all pointers are stored as shared_ptrs > [members]. I think this is already [almost] the case. Do we ever create > Profile on the fly like this for example? I don't think so... > > It's true that we would still have to return shared_ptrs as objects from > any function which creates a new object, however. But I don't think there > is any problem with having incomplete class declaration at this point, is > there? The problem here is that it is unsafe practice and that goes against idea of smart pointers. We can easily avoid this with DEFINE_REF_COUNTER, because we are using intrusive reference counting and we have full control over class implementations. So why not? It's a flaw of templates that they cannot be compiled separately or maybe it's a flaw of strongly typed language that cannot cope with loads of type declarations. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Mahogany-Developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/mahogany-developers