Boost logo

Glas :

Re: [glas] Reference counting?

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2007-10-12 10:16:13


On Friday 12 October 2007, Bert Rodiers wrote:
> Hello Karl,
>
> In RogueWave they do the following:
> A vector has a view, which on its turn points to the actual data (a C++
> data structure aggregating the data).
> When you for example apply a slice on your vector you get a new vector with
> a different view on the same data (the sharing of the data happens with
> reference counting, and the view keeps track of the new start, length and
> stride). The data is cleaned up at the moment no views exist anymore. For
> matrices and higher dimension structures they also apply this so that when
> you extract a column from a matrix the data is shared between the original
> matrix and the vector which was the result of the slice.
>

In blitz++ this is also applied to 'components' of an array. For example,
complex has real and imag components. Thus, real(array) is an lvalue! Very
nice, IMO.