Thank you for the answer. Is there any way I can prevent it from copying the stream object even though std::ostream::write() returns a std::ostream&amp; ?<br><br><div class="gmail_quote">On Wed, Sep 29, 2010 at 11:38 AM, Jakub Zytka <span dir="ltr">&lt;<a href="mailto:kubol@kormoran.net">kubol@kormoran.net</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;"><div class="im"><br>
&gt; I get this error:<br>
&gt; *TypeError: No to_python (by-value) converter found for C++ type: class<br>
&gt; std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;*<br>
&gt;<br>
&gt; This is the python function<br>
&gt; *    def serialise(self, gameobj, file):<br>
&gt;          if(gameobj in self.components):<br>
&gt;              file.write(&quot;HEY&quot;, 3)*<br>
&gt;<br>
&gt; What&#39;s the problem here? Is is because the ostream argument is an reference?<br></div>
The problem is you are trying to copy a noncopyable object:<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
             return class_&lt;std::ostream, bases&lt;std::ios&gt;,<br>
boost::noncopyable&gt;(&quot;ostream&quot;, no_init)<br>
</blockquote></div>
ostream is noncopyable<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
                 .def(&quot;write&quot;, write ,<br>
return_value_policy&lt;copy_non_const_reference&gt;())<br>
</blockquote></div>
but you define write to return copy (of ostream)<br>
<br>
_______________________________________________<br>
Cplusplus-sig mailing list<br>
<a href="mailto:Cplusplus-sig@python.org" target="_blank">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>
</blockquote></div><br>