Boost logo

Boost Users :

From: Darin Adler (darin_at_[hidden])
Date: 2002-11-18 13:39:16


On Monday, November 18, 2002, at 09:41 AM, Alexandre Carsac wrote:

> Just wondering if there is some issue to the following problem (a and
> b instance are not in the same block code in true life of course) :
> class A;
> class B : public A ...
>
> void main()
> {
> shared_ptr<A> a;
> shared_ptr<B> b(new B);
> a = b; // what i would like, but it wont compile: no copy ctor
> available
> }

The above is an upcast, not a downcast. It should compile. If not, we
have some sort of shared_ptr bug. But you can't compile a class B that
inherits from A without the definition for class A; we need a real
example here, because there are errors in the shorthand one you
provided.

If you are really talking about polymorphic smart pointer downcasts,
even though your example here shows an upcast, then you probably want
shared_polymorphic_downcast or shared_static_cast. Those are
documented at <http://boost.org/libs/smart_ptr/shared_ptr.htm>.

     -- Darin


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