Boost logo

Ublas :

From: Jon Pearce (j.pearce_at_[hidden])
Date: 2005-03-30 06:58:09

Hi Michael,

Thank you very much for your fast, detailed reply. no_alias() solves the
problem beautifully

>I think the comment line is only there to explain what we logically is about
>to happen. I don't think it was ever part of the compiled code. It really is
>a comment and not a commented out line! The form using assign_temporary is
>used for efficiency.
(Actually, the commented line does compile ;-) and does eliminate the
temporary, but rather dirty to be modifying the original source!)

>Personally I would remove this completely! That way you would get a compile
>time error when you try and construct such a temporary. Also we could get rid
>of the own_ flag which makes shallow_array_adaptor inefficient.

>The correct solution would be to use the following for assignment instead
> c.assign ( xx );
>or the equivilent
> noalias( c ) = xx;
>Hopefully that works. Have you tried the same with 'array_adaptor'?

I have now switched to array_adaptor - thank you for pointing this out

I notice that *any* call to internal_resize() in array_adaptor,
unbounded_array and shallow_array_adaptor triggers a reallocation, even
if the new size is smaller than the old

void resize_internal (size_type size, value_type init, bool
preserve = true) {
if (size != size_) {
pointer data = new value_type [size];

Might there be a benefit in replacing this with "if(size < size_)" in a
future version of UBlas? (I think that this is what is done in

Thanks again for your time

Yours gratefully