Boost logo

Boost :

From: Brian Gray (briangray_at_[hidden])
Date: 2003-03-04 21:39:06


On Tuesday, March 4, 2003, at 05:36 PM, Andrei Alexandrescu wrote:
> "Brian Gray" <briangray_at_[hidden]> wrote in message
> news:134BA7DC-4E86-11D7-81C4-00039375675E_at_mac.com...
>> I can see how vector<Derived*> might benefit from conversion to
>> vector<Base*>, but we're talking about contiguous memory here. Very
>> subject to raw object size, so there's no way to cast between the two
>> and preserve object hierarchies if they're not pointers.
>
> The conversion vector<Derived*> to vector<Base*> is unsound. What, are
> we
> going the way of Java containers? :o)

Heh, maybe I could have phrased it a bit better. Yes, a vector of
Deriveds IS_NOT_A vector of Bases. But I can see how a developer might
wish to make the conversion, however ill-advised. An int IS_NOT_A
float, but people often want to convert between them. What the OP was
suggesting is a whole other ball of wax. It would be like having a
struct, and casting it to another arbitrary struct, mapping the memory
to whatever members happened to sit there. Or bitwise replication of a
float's representation into an int variable. Quite a mess.

  -- Brian


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