[C++-sig] Wrapping std::vector<AbstractClass*>
Joel de Guzman
djowel at gmail.com
Thu Jul 7 16:07:03 CEST 2005
Joel de Guzman wrote:
> Paul Melis wrote:
>
>>Hello,
>>I have an abstract class and a std::vector<> of pointers to this class.
>>A routine in my c++ code fills a vector with objects of classes derived
>>from the abstract class.
>>I'd like to iterate over the vector in python and use each of the items
>>in the vector depending on the type of derived class.
>>
>
> [...]
>
>>I suspect that boost.python will wrap the return value of returnList()
>>as a pointer to Abstract, without the possibility at runtime to look at
>>the actual object type. Is this something I would have to code by hand?
>>For example, by making a routine that takes a pointer to Abstract and
>>uses dynamic_cast<> to test which of the concrete classes the object
>>actually is from?
>
>
> Pardon the delay. It's been a while. I'm investigating the problem
> in more detail. I'll get back to you on this, ok?
Ok... Replying to myself...
I committed a fix. The problem occurs when lst[0] tries to return
a copy and there's no way to provide a call policy. So, the
behavior now is for wrapped containers of pointers to always
return by internal reference.
Cheers,
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net
More information about the Cplusplus-sig
mailing list