Boost logo

Glas :

Re: [glas] MTL3 design ? [was MTL project site is up]

From: Jeremy Graham Siek (jsiek_at_[hidden])
Date: 2005-02-01 21:06:13


Hi Dave, Toon,

On Feb 1, 2005, at 3:55 PM, David Abrahams wrote:
>> operator= for vectors does not require both vectors to have the same
>> size. Thus the lhs will be resized to the size of the rhs. But again
>> this poses a problem with stack-based objects because they can't be
>> resized. And why actually do you prefer to resize the lhs instead of
>> requiring that both vectors have the same size?
>
> I haven't given that question much thought yet, and I don't know
> Jeremy's rationale, but I can guess: stack objects with different
> sizes also have different types, so we can enforce incompatibility at
> compile-time. We can't do the same with other objects, and there's no
> obvious reason to impose an incompatibility restriction. I can
> imagine that it becomes quite inconvenient and even expensive in some
> cases. For example, constructing unity and identity matrices might be
> more painful than neccessary.
>
> Jeremy, can you comment on this?

Yes, I think you've guessed all the reasons I was thinking of.

Cheers,
Jeremy

_______________________________________________
Jeremy Siek <jsiek_at_[hidden]>
http://www.osl.iu.edu/~jsiek
Ph.D. Candidate, Indiana University Bloomington
C++ Booster (http://www.boost.org)
_______________________________________________