I would like to share the contents of an array of doubles a
of size k
with one or more STL vectors v1
, v2
...vn
.
The effect that I want from this shared storage is that if the underlying array gets modified the change can be observed from all the vectors that share its contents with the array.
I can do that by defining the vectors v1
...vn
as vectors of pointers
vector<double*> v1;
and copy the pointers a
to a + k
into this vector. However, I do not like that solution. I want the vectors to be a vector of doubles.
Given that you can extract the underlying pointer from a vector I am assuming one could initialize a vector with an array in such a way that the contents are shared. Would appreciate help about how to do this.