Here's my situation:
I'm given data as a pointer say double*
.
I want to wrap this in a vector
to use a library, and to avoid messing around with pointers.
Not wanting to copy the entire array, I use a vector of reference wrappers. If I then want to get the double*
back from said vector
after using the library, can I get this by casting the vector.data()
function?
For example:
double* arr = new double[10];
vector<reference_wrapper<const double> > vec(arr,arr+10);
//use library in some manner.
//is this allowed? is there a more appropriate way?
//or should I forget using reference_wrappers in this way.
double* res = (double*) vec.data()