[C++-sig] shared_ptr converters

Nicodemus nicodemus at globalite.com.br
Mon Apr 21 16:41:12 CEST 2003


David Abrahams wrote:

>Nicodemus <nicodemus at globalite.com.br> writes:
>  
>
>However, there is one significant difference: if you don't specify
>shared_ptr<Y> then you will not be able to pass a Python X object as a
>shared_ptr<Y>& argument.  Among other things that means you will not
>be able to expose member functions of the shared_ptr as methods of the
>wrapped X (see Raoul Gough's recent postings about proxies).  You will
>still be able to pass a Python X object as shared_ptr<X>,
>shared_ptr<Y>, shared_ptr<X> const&, or shared_ptr<Y> const&.
>

You mean that a function that receives a shared_ptr<X>& wouldn't work? 
Because the following does:

int Test(boost::shared_ptr<A>& a)
{
    return a->f();
}          

 >>> from test import *
 >>> a = New()
 >>> Test(a)
1

Or am I misunderstood your response? If the only drawback is not being 
able to expose member functions of the shared_ptr as methods of the 
wrapped object, I think it is acceptable for Pyste to do the more common 
thing, since this is a rare use case anyway. 8)

Regards,
Nicodemus.







More information about the Cplusplus-sig mailing list