[C++-sig] ArgumentError when use the shared_ptr (original) (raw)

ZaeX zaexage at gmail.com
Tue Jan 27 13🔞52 CET 2009


Thanks, Roman. It solved the problem. Can't believe this '&' takes me two days.

On Tue, Jan 27, 2009 at 4:26 PM, Roman Yakovenko <roman.yakovenko at gmail.com>wrote:

2009/1/27 ZaeX <zaexage at gmail.com>: > Hi, c++-sig: > > I got a problem involving sharedptr here, > according to some threads here I believed it should be solved by > implicitlyconvertible, > 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 vec; > public: > A(){} > A(boost::sharedptr& ptr) :vec(ptr->vec) > std::vector& GetV(){return vec;} > }; > > class D > { > boost::sharedptr maa; > public: > boost::sharedptr& GetAA() {return maa;} > }; > > implicitlyconvertible<boost::sharedptr, A>(); > /////////////////////////////////////// > I exported the A and D, and also added the implicitlyconvertible > 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.

I suggest you not fight with Boost.Python - pass/return sharedptr<...> by value. The code will start to work. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/


Cplusplus-sig mailing list Cplusplus-sig at python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

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



More information about the Cplusplus-sig mailing list