From: Michael Stevens (mail_at_[hidden])
Date: 2005-09-13 11:32:30
On Dienstag 13 September 2005 16:05, Vardan Akopian wrote:
> Hi Ott,
> You should be using shallow_array_adaptor as in
> Note that shallow_array_adaptor has been removed from boost-1.33, and
> a new adaptor carray_adaptor has been introduced. So if you update to
> boost-1.33 you may need change your code accordingly.
Quick correction. 'array_adaptor' and 'shallow_array_adaptor' are still in
boost 1.33.0. In fact I just commited a fix to allow the latter to compile in
gcc-4.0. This fix would included in 1.33.1 if it comes out.
The existing array adaptors have been around for a while but have some nasty
aspects. Your example highlights one example. At the line
vector<double, array_adaptor<double> > v(4, st);
is copy constructed. This results in a new memory being allocated and the
array_adaptor no longer references the original array. shallow_array_adaptor
avoids this but is not perfect with regard to efficiency.
shallow_array_adaptor and array_adaptor should probably be replaced. To this
end in the currect CVS head they have been removed (possible temporarily).
Vardan had some good ideas about how this should progress, but I have not
been able to take code much further.