Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-04-09 09:49:27

Am Montag, 9. April 2007 14:55 schrieb Neal Becker:

> Sorry, I'm not sure what you mean. Do you mean that this only fixes
> vector<unbounded_array> and not other dense vector<storage...> ?

This fix applies of course for all storage types.

> I know, also matrix is not addressed. My intention was to find out
> if we have some agreement that this is the preferred approach. If
> there is some agreement, I'll try to provide a more complete patch.

We should update the container concept and the storage concept.

*From storage concept*

Resize 1: a.resize(n, t)

The container may be reallocated if its size changes. Existing element
values are preserved, additional elements are copies of t.

Resize 2: a.resize(n)

The container may be reallocated if its size changes. Element values are
uninitialized. That is, each element value may be a previously assigned
value or default constructed value for T.

*From container concept*

Resize: v.resize (n[, p]);

Erases or appends elements in order to bring the vector to the
prescribed size. Appended elements copies of value_type(). When p ==
false then existing elements are not preserved and elements will not
appended as normal. Instead the vector is in the same state as that
after an equivalent sizing constructor.


Before we update the code we should agree for a common concept.

About storage classes - We already have additionally to resize 1 and 2:

void resize_internal (const size_type size, const value_type init, const
bool preserve);

So we could modify the resize-concept to be:

resize(n[, preserve = false[, init = false[, value = T()]]]);

The container may be reallocated if its size changes. The values of old
elements are preserved if <code>preserve</code> is true. New elements
are initialized with <code>value</code> if <code>init</code> is true.
If <code>init</code> is false then new values are default constructed
unless <code>detail::has_trivial_constructor&lt;T&gt;::value</code> is

<code>resize(n,t)</code> is the short form of

What do you think?