Chaps and Chapesses!

I too am not championing the idea of putting shared_ptr into OSG. However I
did not want to discount the idea completely. Mathais points out the count
instance problem of a naive implementation. I also work on the Boost.Range
library and I was therefore thinking that with a small modification to
shared_ptr to use non-member functions to increment and decrement the use
count that it would be possible to provide a specialisation for
osg::Referenced. However after further thought this implementation would be
highly error-prone and require too many specialisations to be practical.

Therefore the best option in my opinion is to provide interoperation with
other intrusive smart pointers such as boost::intrusive_ptr.

This situation may well change after C++09 if the addition of template
typedefs is included, since this would remove the objections to the policy
based smart pointers that would simply remove most of these interoperation
difficulties. Perhaps a review in about three or four years time is in
order!

I'll prototype interoperation with boost::intrusive_ptr in my spare time (It
may therefore be a while).

Regards,
Neil Groves

On Thu, Oct 2, 2008 at 8:08 AM, Ulrich Hertlein <[EMAIL PROTECTED]>wrote:

> Hi,
>
> On 2/10/08 4:27 PM, Mathias Fröhlich wrote:
>
>> Code like this:
>>
>> shared_ptr<Node>  node(new Node);
>> Node* rawNode = node.get();
>> shared_ptr<Node>  nodePointerWithDifferentReferenceCountObject(rawNode);
>>
>> This will end up with two different reference count instances for a single
>> object instance.
>>
>
> Yes, but this is a usage error w.r.t. shared_ptr<>.
> You always need to pass the shared_ptr<> but that works just as well.
>
>  Note that this kind of usage pattern happens quiet often in osg ...
>> ... think of adding nodes to a group and adding the same node to an other
>> group and many more.
>>
>
> The OSG API would have to be adapted of course so that the raw pointers are
> never passed back but only references (or copies) of the internal
> shared_ptr<>.
>
> I'm not trying to advocate usage of shared_ptr<> in OSG, I'm just saying it
> could be done - but it would also break a lot of code.
>
> Cheers,
> /ulrich
>
> _______________________________________________
> osg-submissions mailing list
> [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to