Boost logo

Ublas :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2007-04-24 11:25:03

> 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.
> *thoughts*
> 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
> true.
> <code>resize(n,t)</code> is the short form of
> <code>resize(n,true,true,t);</code>
> What do you think?
> mfg
> Gunter

seems good, but I would suggest
modify storage resize-concept to:

resize (n[, preserve=false[, do_init=default_do_init[, value=T()]]]);
where default_do_init is !detail::has_trivial_constructor

That will simplify the above description, and I think is a bit more logical.

Also, it seems all instances of resize which take an init value pass by
value. Shouldn't that be const&?