jeudi 26 février 2015

How to get a reference to an array from a pointer to that array


Simple question. I have a pointer to an array.



vector<int> myVector = { 22, 18, 12, -4, 58, 7, 31, 42 };
int* myPtr = myVector.data();


I also have a function that takes a reference to an array as a parameter.



void sort_quick(T (&arr)[]);


How can I pass my vector's array to this function without having to copy the potentially huge array in data().


Also, I need to pass it as an array, it's a pre-requisite, so don't come talking about just passing the vector because I wish I could.




Aucun commentaire:

Enregistrer un commentaire