logo       

Re: polymorphic smart ptr downcast: msg#00219

lib.boost.user

Subject: Re: polymorphic smart ptr downcast


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


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/JjlUgA/vN2EAA/xGHJAA/EbFolB/TM
---------------------------------------------------------------------~->

Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe@xxxxxxxxxxxxxxx>


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise