-
-
Save jkp/2284716 to your computer and use it in GitHub Desktop.
Boost Python error "No to_python (by-value) converter found..."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm posting this here because I had a maddening search for information about why this error occurs when trying to do certain tasks in a Boost Python binding to a C++ object: | |
TypeError: No to_python (by-value) converter found for C++ type: Element* | |
This was when trying to iterate over a vector, defined as: | |
typedef std::vector<Element*> ElementList; | |
It turns out that in your `class_<>` definitions you have to be pretty specific. I already had: | |
class_<Element>("Element") | |
... | |
but what solved this error was to specify that this class could _also_ have a pointer type: | |
class_<Element, Element*>("Element") | |
... | |
After adding the pointer type to the class definition, the error went away! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment