[C++-sig] Shared pointers and python subclasses
Chad Austin
caustin at gmail.com
Fri Sep 10 08:56:33 CEST 2004
When binding the RecordHandler subclass, you could try:
implicitly_convertable<SubClassPtr, RecordHandlerPtr>();
Boost.Python can't automatically figure out which HeldTypes are
implicitly convertible (atm), so you have to tell it.
Cheers,
Chad
On Thu, 09 Sep 2004 17:17:18 -0400, Itamar Shtull-Trauring
<itamar at itamarst.org> wrote:
> I have a structure somewhat like this (I simplified to explain):
>
> typedef boost::shared_ptr<RecordHandler> RecordHandlerPtr;
> class_<RecordHandler, RecordHandlerWrap>("RecordHandler");
> class_<CacheRecordRetriever>("CacheRecordRetriever",init<RecordHandlerPtr>());
>
> Now, if I subclass RecordHandler in python, I can't pass an instance of
> the subclass to CacheRecordRetriever's constructor in my Python code, it
> raises a RuntimeErorr claiming it's the wrong type. How do I solve this?
>
> Thanks!
>
> --
> Itamar Shtull-Trauring http://itamarst.org
More information about the Cplusplus-sig
mailing list