On Fri, 3 Oct 2003 16:43:52 +0200 (CEST) Robert Vazan <[EMAIL PROTECTED]> wrote:
RV> On Fri, 3 Oct 2003 15:33:55 +0200 (Romance Daylight Time) Vadim Zeitlin
RV> <[EMAIL PROTECTED]> wrote:
RV>
RV> > Anyhow, just one point: I realized that I don't understand at all what is
RV> > your objection to shared_ptr<> is. You can use shared_ptr<incomplete_type>,
RV> > the only requirment is that the type be complete at the point where the
RV> > destructor is called. If the dtor of containing class is not inline, it
RV> > should be ok...
RV>
RV> Return chains call destructors.
RV>
RV> shared_ptr<Profile> GetProfile() const
RV> { return m_someMember->GetProfile(); }
I wonder what should our convention be for the functions like this. I'm
not sure that returning objects is the best idea efficiency-wise. There are
at least 2 other alternatives:
1. return raw pointer (no problem here as long as it's assigned to
shared_ptr in the caller, but, unlike when returning the object,
you can't ensure this -- still, in practice, I don't see any problems
with this, do you?)
2. return const shared_ptr reference: this, of course, supposes that all
pointers are stored as shared_ptrs but this is the goal anyhow
What do you think? It would be nice to add a tiny technote about this when
the dust settles.
RV> Inline functions that keep local pointers call destructors.
RV>
RV> void SomeMethod()
RV> {
RV> shared_ptr<Profile> profile(mApplication->GetProfile());
RV> profile->SomeFunction();
RV> }
If we do either (1) or (2) from above this problem would disappear as
well.
Regards,
VZ
-------------------------------------------------------
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