[C++-sig] TypeError: No to_python (by-value) converter found for C++ type: class std::basic_ostream<char, struct std::char_traits<char> >

Simon W simwarg at gmail.com
Wed Sep 29 14:11:20 CEST 2010


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& ?

On Wed, Sep 29, 2010 at 11:38 AM, Jakub Zytka <kubol at kormoran.net> wrote:

>
> > I get this error:
> > *TypeError: No to_python (by-value) converter found for C++ type: class
> > std::basic_ostream<char,struct std::char_traits<char> >*
> >
> > This is the python function
> > *    def serialise(self, gameobj, file):
> >          if(gameobj in self.components):
> >              file.write("HEY", 3)*
> >
> > What's the problem here? Is is because the ostream argument is an
> reference?
> The problem is you are trying to copy a noncopyable object:
>
>
>              return class_<std::ostream, bases<std::ios>,
>> boost::noncopyable>("ostream", no_init)
>>
> ostream is noncopyable
>
>
>                  .def("write", write ,
>> return_value_policy<copy_non_const_reference>())
>>
> but you define write to return copy (of ostream)
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100929/9bb92fb3/attachment.html>


More information about the Cplusplus-sig mailing list