[C++-sig] Re: iterators and abstact base class
Francois Ostiguy
ostiguy at fnal.gov
Thu Mar 11 18:43:16 CET 2004
On Wed, 10 Mar 2004, David Abrahams wrote:
> > I want to achieve in python
> >
> > b1 = B(..) # appropriate contructor
> > b2 = B(..) #
> > c = C(b1, b2) # constructs a C which contains b1 and b2
> > i = I(c) # i is an iterator for c
> >
> > a = i.next() <<<<==== this is the problem. i.next() must return something
> > that can be held into python object a. In C++
> > i.next() returns a type A*.
> >
> > a.function()
> >
> > ...
> >
> > How do I define a python type that can be used to hold what i.next() returns ?
>
> I don't understand the problem. Why not wrap "A" using class_; then
> wrap next() with reference_existing_object or another appropriate call
> policy?
>
I am affraid the problem is sitting in front of my keyboard.
I guess I did not fully appreciate the fact that introspection allows
one to determine the dynamic type of an object and to return a reference
to the full type intead of a reference to a base class object.
Thanks again!
-Francois
----------------------------------------------------------------------------
Dr. Jean-Francois OSTIGUY voice: (630) 840-2231
Beam Physics Dept MS220 FAX: (630) 840-6039
Fermi National Accelerator Laboratory email: ostiguy at fnal.gov
Batavia IL 60510-0500 WWW:www-ap.fnal.gov/~ostiguy
More information about the Cplusplus-sig
mailing list