Hi,

On Friday, August 02, 2013 19:39:33 Ulrich Hertlein wrote:
> std::make_shared allocates object and ref-counter in one allocation :-)
Hmm, this requires either a lefthand reference constructor to be called 
additionally to the original one that you just need. If you have everything 
inline that's relatively fine, especially if you have more or less simple 
classes, the compiler can relatively well optimize this away. If you either 
have implemented these in the implementation file you already rely on link time 
optimiziation to find this. Very often not switched on, and if so usually not 
that agressive to really find these opportunities. Or of you do not have the 
lefthand reference constructor implemented, you end up doing a copy 
constructor which is actually way worse than what we are talking about.

> C++11 also has std::enable_shared_from_this which solves some issues, but
> still hasn't the same semantics as osg::ref_ptr.
Also this one, just says that you can get a shared pointer from a plain one. 
As far as I can see this says nothing about the storage layout or the amount 
of allocations it uses. And actually there are implementations implementing 
this just by storing a weak_ptr to this in the base class and on calling 
shared_from_this you get the shared pointer from the weak pointer inside.

Greetings

Mathias
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to