Thanks, Roman. It solved the problem.<br>Can&#39;t believe this &#39;&amp;&#39; takes me two days.<br><br><div class="gmail_quote">On Tue, Jan 27, 2009 at 4:26 PM, Roman Yakovenko <span dir="ltr">&lt;<a href="mailto:roman.yakovenko@gmail.com">roman.yakovenko@gmail.com</a>&gt;</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 &lt;<a href="mailto:zaexage@gmail.com">zaexage@gmail.com</a>&gt;:<br>
<div><div></div><div class="Wj3C7c">&gt; Hi, c++-sig:<br>
&gt;<br>
&gt; I got a problem involving shared_ptr here,<br>
&gt; according to some threads here I believed it should be solved by<br>
&gt; implicitly_convertible,<br>
&gt; however after many tries, I still cannot make it work. although this problem<br>
&gt; may look old, I really need your help or hint.<br>
&gt; My environment is WinXP + python 2.5.4 + boost1.36<br>
&gt; /////////////////////////////////////////<br>
&gt; class A<br>
&gt; {<br>
&gt; &nbsp; &nbsp; std::vector&lt;int&gt; vec;<br>
&gt; public:<br>
&gt; &nbsp; &nbsp; A(){}<br>
&gt; &nbsp; &nbsp; A(boost::shared_ptr&lt;A&gt;&amp; ptr) :vec(ptr-&gt;vec)<br>
&gt; &nbsp; &nbsp; std::vector&lt;int&gt;&amp; GetV(){return vec;}<br>
&gt; };<br>
&gt;<br>
&gt; class D<br>
&gt; {<br>
&gt; &nbsp; &nbsp; boost::shared_ptr&lt;A&gt; m_aa;<br>
&gt; public:<br>
&gt; &nbsp; &nbsp; boost::shared_ptr&lt;A&gt;&amp; GetAA() {return m_aa;}<br>
&gt; &nbsp;};<br>
&gt;<br>
&gt; implicitly_convertible&lt;boost::shared_ptr&lt;A&gt;, A&gt;();<br>
&gt; ///////////////////////////////////////<br>
&gt; I exported the A and D, and also added the implicitly_convertible<br>
&gt; but when I tried to do this in python:<br>
&gt;<br>
&gt; d = D()<br>
&gt; a = d.GetAA()<br>
&gt; a.GetV()<br>
&gt;<br>
&gt; Python interpreter will complains<br>
&gt; Boost.Python.ArgumentError: Python argument types in<br>
&gt; &nbsp; &nbsp; A.GetV(A)<br>
&gt; did not match C++ signature:<br>
&gt; &nbsp; &nbsp; GetV(class A {lvalue})<br>
&gt; ---------------------------------------------------------------------<br>
&gt; 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&lt;...&gt; 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>