Boost logo

Boost :

From: Jon Kalb (jonkalb_at_[hidden])
Date: 2003-02-12 11:24:40


On 2003-02-12 5:56 AM, "Philippe A. Bouchard" <philippeb_at_[hidden]>
wrote:

> Jon Kalb wrote:

>> I wonder if it wouldn't be better to have a compile time error in this
>> situation rather than to create a trap for the unsuspecting. It does
>> put an additional burden on the user to ensure that the types are
>> indeed polymorphic, but I think they have that burden in any case.
>> The currently implementation allows them to be blissfully ignorant of
>> this situation.
>>
>> I appreciate that your library will document that it only works for
>> polymorphic types, but I fear that to be an insufficient prophylactic.
>
> Well in fact, the following assignment could be verified at compile-time
> with some smart_ptr<> checking policy:
>
> class A { char c; };
>
> class B { char c; };
>
> class C : public A, public B { char c; };
>
>
> smart_ptr<C> pC = new C;
>
> smart_ptr<A> pA = pC; // Ok.
>
> smart_ptr<B> pB = new B; // [<- correction here] Ok.
>
> smart_ptr<B> pA = new C; // Ok.
>
> smart_ptr<B> pB = pC; // Generate compile-time error.
>
>
>
> Philippe A. Bouchard

I'm afraid that I don't see your point. How is this relevant?

Jon Kalb
jonkalb_at_[hidden]


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