[osg-users] Returning ref_ptr<> vs. ref_ptr<>::get()

Paul Speed pspeed at progeeks.com
Wed Sep 10 11:36:46 PDT 2008



Cliff Taylor wrote:
> 
> If I remember correctly, Java purposely doesn't give you access to the
> base addresses its references point to.  At least, I can't think of an
> easy way to access them.  This is all in the name of safe garbage
> collection and "data hiding", which ref_ptr<>::get() feels like it's
> breaking, at least to me.  Shouldn't we let ref_ptr<> do it's job and
> not mess with its internal structures, for the same reason we
> shouldn't call ref() and unref() on osg::Referenced family objects?
> 

One thing to remember is that garbage collection (as in Java) is 
different than managed pointers.  The first is a full solution, the 
second is a nice helper.  For example, Java handles circular references, 
doesn't require "buy in" by all containing classes, etc..  ref_ptr 
doesn't have this luxury so it is frequently necessary to work around it.

In light of that, it would be impossible to get rid of get().
-Paul (a different Paul. ;))






More information about the osg-users mailing list