Boost logo

Boost :

From: boost (boost_at_[hidden])
Date: 2001-12-07 06:56:24


Salut,

On Friday 07 December 2001 09:29, Toon Knapen wrote:
> jhrwalter wrote:
> > Do we really need reserve()? IMO the allocation behaviour of resize()
> > is a quality of implementation issue, especially since resize() is a
> > method of the proxy concept. If we intend to make it's behaviour
> > transparent, we'd have to introduce capacity() first.
>
> I find this really necessary (there's also a good reason why they have
> capacity and size in std::vector). Everytime you shrink the vector or
> matrix (i.e. resize(x) with x < size() ), you are going to delete[] the
> old data and new[] another array. This is very time consuming.
> I would suggest to allign totally with what std::vector does : you can
> resize without reallocation (if the capacity is large enough) and you
> can easily shrink the capacity by copying to a smaller vector.

I agree.
Allthough a submatrix adapter would be sufficient for me.

> > BTW, do we need to consider std::allocator?
>
> In the long term : yes. But no allocater can be as smart as what you
>
> can do with capacity() and resize(). So the allocator is not a solution
>
> to the above problem.
> An allocator would be nice e.g. to optimise allocation of many small
> matrices.
I agree.

Peter


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