Thanks, Roman. It solved the problem.<br>Can't believe this '&' takes me two days.<br><br><div class="gmail_quote">On Tue, Jan 27, 2009 at 4:26 PM, Roman Yakovenko <span dir="ltr"><<a href="mailto:roman.yakovenko@gmail.com">roman.yakovenko@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">2009/1/27 ZaeX <<a href="mailto:zaexage@gmail.com">zaexage@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> Hi, c++-sig:<br>
><br>
> I got a problem involving shared_ptr here,<br>
> according to some threads here I believed it should be solved by<br>
> implicitly_convertible,<br>
> however after many tries, I still cannot make it work. although this problem<br>
> may look old, I really need your help or hint.<br>
> My environment is WinXP + python 2.5.4 + boost1.36<br>
> /////////////////////////////////////////<br>
> class A<br>
> {<br>
> std::vector<int> vec;<br>
> public:<br>
> A(){}<br>
> A(boost::shared_ptr<A>& ptr) :vec(ptr->vec)<br>
> std::vector<int>& GetV(){return vec;}<br>
> };<br>
><br>
> class D<br>
> {<br>
> boost::shared_ptr<A> m_aa;<br>
> public:<br>
> boost::shared_ptr<A>& GetAA() {return m_aa;}<br>
> };<br>
><br>
> implicitly_convertible<boost::shared_ptr<A>, A>();<br>
> ///////////////////////////////////////<br>
> I exported the A and D, and also added the implicitly_convertible<br>
> but when I tried to do this in python:<br>
><br>
> d = D()<br>
> a = d.GetAA()<br>
> a.GetV()<br>
><br>
> Python interpreter will complains<br>
> Boost.Python.ArgumentError: Python argument types in<br>
> A.GetV(A)<br>
> did not match C++ signature:<br>
> GetV(class A {lvalue})<br>
> ---------------------------------------------------------------------<br>
> Can you give some help on this, I have been stuck here for 2 days.<br>
<br>
</div></div>I suggest you not fight with Boost.Python - pass/return<br>
shared_ptr<...> by value.<br>
<br>
The code will start to work.<br>
<font color="#888888"><br>
--<br>
Roman Yakovenko<br>
C++ Python language binding<br>
<a href="http://www.language-binding.net/" target="_blank">http://www.language-binding.net/</a><br>
_______________________________________________<br>
Cplusplus-sig mailing list<br>
<a href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/cplusplus-sig" target="_blank">http://mail.python.org/mailman/listinfo/cplusplus-sig</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Time is mana, we must hurry<br>