Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_array] Why the precondition on assignment?
From: Peter Barker (newbarker_at_[hidden])
Date: 2009-02-27 08:49:12


On Thu, Feb 26, 2009 at 8:14 PM, alfC <alfredo.correa_at_[hidden]> wrote:
> Now that you mentionad the example of std::vector. I am wondering
> whether such manual control of multi_array reserved space is THE
> solution.
> something like
>
> A.reserve({{shape1,shape2,shape3}}); // or just reserve
> (shape1*shape2*shape3)

Would this still make it necessary to write an operator= in a class
that has a multi_array as a member? That's the main thing I'd like to
avoid as it introduces a maintenance burden to ensure all the other
members are copied.

Because of that I think multi_array::operator= must be the exception
to a strategy on avoiding reallocations. If the existing space can be
used, then all well and good - have that optimisation.

Thanks for explaining a bit more about multi_array and comparison of
it with std::vector.

Regards,

Pete


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net