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& ?<br><br><div class="gmail_quote">On Wed, Sep 29, 2010 at 11:38 AM, Jakub Zytka <span dir="ltr"><<a href="mailto:kubol@kormoran.net">kubol@kormoran.net</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;"><div class="im"><br>
> I get this error:<br>
> *TypeError: No to_python (by-value) converter found for C++ type: class<br>
> std::basic_ostream<char,struct std::char_traits<char> >*<br>
><br>
> This is the python function<br>
> * def serialise(self, gameobj, file):<br>
> if(gameobj in self.components):<br>
> file.write("HEY", 3)*<br>
><br>
> What'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_<std::ostream, bases<std::ios>,<br>
boost::noncopyable>("ostream", 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("write", write ,<br>
return_value_policy<copy_non_const_reference>())<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>