Boost logo

Ublas :

From: Hongzheng Wang (wanghz_at_[hidden])
Date: 2008-06-01 03:17:29


I scanned the archives of mailing lists for the usage of
array_adaptor<>. It seems that the typical usage is as the following

double extdat[N];
array_adaptor<double> aa(N, extdat);
vector<double, array_adaptor<double> > vd(N, aa);

By tracing the codes, I found that aa and extdat are sharing the same
raw data. That is, &[0] points to extdat. But vd does not
shares the data. Instead, when vd is constructed, it seems that a
copy of extdat is created to setup the new vector. So, I wonder what
is the advantage of using array_adaptor. In other words, why not just
use std::copy or even memcopy (if the layouts are contiguous) to do
the same thing? Is there any special design purpose in inventing

Thanks in advance.