Boost logo

Boost :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2002-02-13 11:01:59


On Wednesday, February 13, 2002, at 01:48 PM, nbecker_at_[hidden] wrote:

>>>>>> "garcia" == garcia <rgarcia1771> writes:
>
> garcia> --- In boost_at_y..., nbecker_at_f... wrote:
>>> Default constructed array is then resized to the correct size.
>
> garcia> Could you provide a code example that shows where this
> functionality
> garcia> is needed? It seems dangerous to have the copy semantics
> of an array
> garcia> depend upon whether or not it was default constructed, not
> to mention
> garcia> whether it had been copied to already or not.
>
> I think it is easy to think of examples where the size is not known at
> construction time. For example, an array that is a member of a
> class. Default constructor is used because we don't know the correct
> size when the class is constructed. Later when a class member
> function is called, the size is known and the array is resized.
>
> I don't know why you say "have the copy semantics of an array depend
> upon whether or not it was default constructed..." Are you saying
> that in order to allow resizing that this is a necessary consequence?

If a default-constructed array should be resized, why not just
use operator= and assign an array with the correct dimensions,
once those are known?

Matthias


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