HI Hartwig,

I attempted at having different return types with Object::clone() in
different subclasses many years ago but different compilers would
accept or not accept this usage, it simple wasn't portable enough to
roll out.

If you know the type and want to clone without doing the extra C++
legwork you can use the osg::clone(..) method i.e.

   osg::Texture2D* orig_texture; = ....
   osg::ref_ptr<osg::Texture2D> new_texture = osg::clone(orig_texture);

This will do the required dynamic for you.

If you are worried about the cost of the dynamic cast then you could
just explicitly call the copy constructor:

   osg::ref_ptr<osg::Texture2D> new_texture = new osg::Texture2D(*orig_texture);

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

Reply via email to