Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-03-31 01:21:47


Hi Jon,

On Wednesday 30 March 2005 13:58, Jon Pearce wrote:
> (Actually, the commented line does compile ;-) and does eliminate the
> temporary, but rather dirty to be modifying the original source!)

I think we should remove those lines or at least replace them with a more
meaningful comment!

> >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.
>
> Absolutely!

OK something to put on the TODO list, unless anyone objects?

> >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 think array_adaptor is relatively untested so any feedback is a good thing.

> 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
> e.g.
>
> BOOST_UBLAS_INLINE
> 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
> std::vector<T>::resize())

Interesting. The problem is to implement if(size < size_)" the storage types
would have to track both the capacity and the size. This would introduce an
undesirable (if small) overhead in the many cases where such resizes are a
rarity.

I guess it depends on what semantics users expect. What do people prefer?

Michael