[C++-sig] Re: to_python (by-value) converter

David Abrahams dave at boost-consulting.com
Thu Sep 11 05:42:11 CEST 2003


Simon Ouellet <simon.ouellet at orthosoft.ca> writes:

> Hi,
>
> I'm using boost::python for embedding python into my application.
>
> I defined a module that containt a class_<Vector>.
>
> I can successfully instantiate a Vector in the embedded python but
> I cannot create a python::object containing a Vector in C++
>
> Vector aVector;
> python::object(aVector);
> this statement gave me an error:
>
> TypeError: No to_python (by-value) converter found for C++ type:
> N3Osm13MotionCapture6VectorE
>
>
> Where N3Osm13MotionCapture6VectorE is my class Vector that has a default
> copy constructor publicly available. 
>
> What could be the problem? and what should I do to fix it?

I can only guess that the C++ type "Vector" that you're wrapping below
is not the same as Osm::MotionCapture::Vector, the type in the error
message.  Could you post a complete, reproducible test case?

Did you base your code on the contents of the
libs/python/test/embedding.cpp file?

For what it's worth, this:

>  mGlobals["SomeVector"] = python::object(aVector);
                            ^^^^^^^^^^^^^^^       ^

is redundant.

   mGlobals["SomeVector"] = aVector;

is equivalent.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list