[C++-sig] ArgumentError when use the shared_ptr<T>

ZaeX zaexage at gmail.com
Tue Jan 27 06:30:16 CET 2009


Hi, c++-sig:

I got a problem involving shared_ptr here,
according to some threads here I believed it should be solved by
implicitly_convertible,
however after many tries, I still cannot make it work. although this problem
may look old, I really need your help or hint.
My environment is WinXP + python 2.5.4 + boost1.36
/////////////////////////////////////////
class A
{
    std::vector<int> vec;
public:
    A(){}
    A(boost::shared_ptr<A>& ptr) :vec(ptr->vec)
    std::vector<int>& GetV(){return vec;}
};

class D
{
    boost::shared_ptr<A> m_aa;
public:
    boost::shared_ptr<A>& GetAA() {return m_aa;}
 };

implicitly_convertible<boost::shared_ptr<A>, A>();
///////////////////////////////////////
I exported the A and D, and also added the implicitly_convertible
but when I tried to do this in python:

d = D()
a = d.GetAA()
a.GetV()

Python interpreter will complains
Boost.Python.ArgumentError: Python argument types in
    A.GetV(A)
did not match C++ signature:
    GetV(class A {lvalue})
---------------------------------------------------------------------
Can you give some help on this, I have been stuck here for 2 days.


-- 
Time is mana, we must hurry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090127/7385c1df/attachment.htm>


More information about the Cplusplus-sig mailing list