[C++-sig] Is there a way to automatically convert a smart_ptr to a held_type (try 2)

David Abrahams dave at boost-consulting.com
Tue Sep 12 05:39:06 CEST 2006


I don't have time to do a complete analysis right now, but maybe I can
help understand these signatures:

"Allen Bierbaum" <abierbaum at gmail.com> writes:

> // Next line shows problem where the object coming back
> // out of C++ can't be compared.  It is like it thinks it has
> // a different type.
>>>> g == core_g
> Traceback (most recent call last):
>  File "<input>", line 1, in ?
> ArgumentError: Python argument types in
>    Group.__cmp__(Group, Group)
> did not match C++ signature:
>    __cmp__(osg::RefPtr<osg::FCPtr<osg::FCPtr<osg::AttachmentContainerPtr,
> osg::NodeCore>, osg::Group> >,
> osg::RefPtr<osg::FCPtr<osg::FCPtr<osg::AttachmentContainerPtr,
> osg::NodeCore>, osg::Group> >)

It's not that the Python types are different (both are Group).  It's
much more likely that they have a different way of holding their
internal C++ osg::Group object such that one can be converted to that
RefPtr type and the other can't.  What can be converted is up to the
converters you've registered.

> // This line shows the same problem with __hash__
>>>> hash(core_g)
> Traceback (most recent call last):
>  File "<input>", line 1, in ?
> ArgumentError: Python argument types in
>    Group.__hash__(Group)
> did not match C++ signature:
>    __hash__(osg::RefPtr<osg::FCPtr<osg::FCPtr<osg::AttachmentContainerPtr,
> osg::NodeCore>, osg::Group> >)
>
> // And here is the problem comparing to None
>>>> g == None
> Traceback (most recent call last):
>  File "<input>", line 1, in ?
> ArgumentError: Python argument types in
>    Group.__cmp__(Group, NoneType)
> did not match C++ signature:
>    __cmp__(osg::RefPtr<osg::FCPtr<osg::FCPtr<osg::AttachmentContainerPtr,
> osg::NodeCore>, osg::Group> >,
> osg::RefPtr<osg::FCPtr<osg::FCPtr<osg::AttachmentContainerPtr,
> osg::NodeCore>, osg::Group> >)
>>>>

This could be a case of the first (self) object not being convertible
to the RefPtr.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list