[C++-sig] Wrap std::vector<pointer*>
matt-bradbury at live.co.uk
Wed Aug 3 23:36:05 CEST 2011
Simon W <simwarg <at> gmail.com> writes:
> >From my research it seems not very trivial to wrap std::vector that holds
pointer types. For example: std::vector<GameObject*>I've looked at boost
python vector_index_suite but it just gives me the runtime error:> TypeError: No
to_python (by-value) converter found for C++ type:> GameObject*I have already
exposed GameObject: class_<GameObject>("
> GameObject") ...
> it have come to my understanding it's not possible with an out of the
> box solution. I have to do some kind of wrapper? Could someone just help
> me out where I should start?Thank you!
I've come across this before as well and use the following to provide support
for vectors of pointers.
I only need to iterate over them so have only modified the __iter__ method.
template <class Container>
: public vector_indexing_suite<Container, true,
typedef iterator<Container, return_value_policy<reference_existing_object>>
template <class Class>
extension_def(Class & cl)
You may want to override functions such as get_item, whose implementation might
static object get_item(Container& container, index_type i)
Anyway have a good look in vector_indexing_suite.hpp to see what is there and
what you might need to hack at.
More information about the Cplusplus-sig