Hi Robert,

I agree that pattern 1 is wins when it comes to clarity. But if you have the 
macro OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION enabled (which it is as 
default) then there is nothing protecting the user from stuffing your returned 
ref_ptr in a raw C pointer.

So with this macro enabled the compiler will gladly compile the code below for 
both pattern. (If you disable it you will get warnings for pattern 1):

Code:
osg::Node* myBadPointerPlzDontDoThis = createObject(); // Stuffing reference 
counted pointers in raw C pointers is bad 



In short: 
Pattern 1 for clarity (and with OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION 
macro disabled some compiler protection against stupidity) 
Pattern 2 for performance. 

Cheers,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56574#56574





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to