[C++-sig] exposing pointers using boost

Furkan Kuru furkankuru at gmail.com
Tue Sep 4 13:44:41 CEST 2007


Hello,

Is there a way to expose structs containing pointers of their types?

Let's say, I have a very simple doubly-linked list.

struct Node {
        Node* next;
        Node* prev;
        int value;
};

I expose it like this:

class_<Node>("Node")
	.def_readwrite("value", &Node::value)
	.def_readwrite("next", &Node::next)
	.def_readwrite("prev", &Node::prev);

When I try to access the next and prev attributes of a Node instance in python,
I get this error:

TypeError: No to_python (by-value) converter found for C++ type: struct Node *


Thanks in advance.

-- 
Furkan Kuru



More information about the Cplusplus-sig mailing list