Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-03-26 21:52:09


----- Original Message -----
From: "Rainer Deyke" <root_at_[hidden]>

>
> I did read this. It say that objects of class Derived may be passed where
> objects of class Derived are expected but type information has been lost.
> However, this only applies when passing the object as an argument, not
when
> calling a method on the object:
>
> struct A { virtual ~A(); }
> struct B : A { void f(); }
> void call_f(B& b) { b.f(); }
> boost::shared_ptr<A> get_B() { return boost::shared_ptr<A>(new B); }
>
> // Wrapper code ommited for brevity.
> // Then in Python...
> b = get_B()
> call_f(b) # This works.
> b.f() # This doesn't.
>
> This strikes me as inconsistent. I suspect that it would be possible to
> remove this inconsistency by modifying 'boost::python::to_python'.

What modification did you have in mind? I don't think I'd want to try to
automatically downcast every returned smart pointer to its most-derived
type...


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk