Dear Readers,

I am submitting a change to ref_ptr to allow the implicit safe conversions.

Frequently I would like code that has a signature like: void
foo(osg::ref_ptr<osg::Node> node) to work for osg::ref_ptr<osg::Group>,
osg::ref_ptr<osg::Geode> etc. The behaviour of osg::ref_ptr does not mimic
the behaviour of a raw pointer in this regard.

To facilitate this possibility I have added a template copy constructor and
a template assignment operator. These work for safe conversions like those
in my previous example, but fail as desired for non-safe conversions since
the template instantiation fails during the raw pointer copy/assignment.

The lack of this facility has appreciably handicapped development of generic
algorithms applied to the scene graph, and I believe that this alteration
will be welcomed by most of the community. If there are issues with
antiquated compilers not supporting template member functions then perhaps a
small piece of conditional compilation is in order.

I have made the change using the latest release version (2.6) as the base.
The full file is attached.

I have not tested building the osg wrappers and the script binding code. I
have tested the legal and illegal conversions of both copying and assignment
to ensure that behave as expected on MSVC7.1, MSVC8, MSVC9, GCC 4.3.

Is the community aware of the 'unspecified_bool_type' idiom used within
boost smart pointers to allow safe conversion to bool? If the community
wishes I would be happy to add this feature.

Thank you for your time and consideration.

Regards,
Neil Groves

Attachment: ref_ptr
Description: Binary data

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

Reply via email to