[osg-submissions] osg::Object::clone

Robert Osfield robert.osfield at gmail.com
Fri Jun 6 06:27:56 PDT 2008


Hi Valary,

Changing the return type of virtual methods in subclasses is only
permitted in more modern compilers, older compilers don't support
this, so I'm afraid I'll have to reject this submission.

As for Michael's and Stephan's assertion that clone() will fail i.e.:

Object* a = new Transform();
Transform* b = dynamic_cast<Transform*>(a->clone());
assert(b);

I believe it would still work fine, a->clone() should call the
Transform->clone(), virtual of it being a virtual function, changing
the return type should not effect this.  If this didn't work then we'd
long had the same problem with the OSG's existing clone method.


Robert.

On Fri, Jun 6, 2008 at 1:24 PM, Валерий Быков <valery.bickov at gmail.com> wrote:
> Hi, Robert!
>
> I suggest to you to override type of returning value in realizations of
> functions osg::Object::clone and osg::Object::cloneType in derived
> classes. In this case one will be able to write simply "osg::Transform*
> sTrans = sExistentTrans->clone();" instead of "osg::Transform* sTrans =
> dynamic_cast<osg::Transform*>(sExistentTrans->clone());".
>
> It is very simple to realize such behavior, three changed files are
> attached in archive, changes are based on revision 8416.
>
> Best regards,
> Valery
>
> _______________________________________________
> osg-submissions mailing list
> osg-submissions at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
>


More information about the osg-submissions mailing list