From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-06-07 02:55:01
Am Donnerstag, 7. Juni 2007 06:09 schrieb Server Levent Yilmaz:
> This is interesting (and obviously works, thank you).. Yet, I can not
> help but mention that the interface of array_adaptor is quite
> counter-intuitive. For instance the following :
> array_vector v(n, array_adaptor(n,array));
> ends up NOT using the adapted pointer but allocating its own space...
> Some reading of the source code reveals that array_adaptor is
> curiously trying to manage its own memory whenever it can (for
> example at copy construction)... Isn't that the job of
> unbounded_array? Isn't the whole purpose of array_adaptor is to
> delegate memory management _wholly_ to the user? (this is no
> rhetoric, really, what else is array_adaptor used for?)
> And curiously asking if I may, why did carray_adaptor removed?
uBLAS assumes deep copy semantics on all data types. Thus the usage of
external storage which can not be reallocated is dangerous and must be
used very carefully. Thus the shallow array adaptor is disabled by
default. You can define
to enable it.
// Array adaptor with shallow (reference) copy semantics of elements.
// shared_array is used to maintain reference counts.
// This class breaks the normal copy semantics for a storage container
// and is very dangerous!
However, these adaptor are quite experimental and need still more
testing (and more documentation).