Boost logo

Boost Users :

Subject: [Boost-users] [boost::python] exposing an abstract base class through boost::ptr_vector and the vector indexing suite
From: Andy Falanga (afalanga) (afalanga_at_[hidden])
Date: 2012-11-01 16:19:45


Hi everyone,

I have need to expose a couple of different classes which inherit from a single, abstract, C++ class. This abstract class is what I need to expose to python. Using the python wiki, I've figure out the correct way to expose these classes. However, the next dimension to this problem is that my users aren't supposed to be able to instantiate any of the derived classes directly. Instead, they are to use a function which will return a list of these objects. I've been working on the correct implementation for use with boost::ptr_vector. Now, I want to use the vector indexing suite in boost::python to expose these things.

I've worked through properly making an assignment overload operator appropriate to this for use with the vector indexing suite. However, I'm stumped at this error:
Error 2 error C2440: 'return' : cannot convert from 'Base' to 'Base *' c:\program files\boost\boost_1_47\boost\python\suite\indexing\vector_indexing_suite.hpp 77

Because of this error, I'm wondering if it's not possible, or at least not recommended, to use the vector indexing suite to expose boost::ptr_vectors. Is this true?

I'm using Visual Studio 2010 and Boost 1.47.

Thanks,
Andy



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net