I have a struct like this:
struct Vector3
{
float data[3];
}
I have another 3rd party library which reads the contents of a file, and loads the data into a vector<float>, which is passed to it by reference:
void ThirdPartyReadData(std::string fileName, std::vector<float> &vecFloat);
I need to give that data to another 3rd party function, which wants the data in the form of vector<Vector3>:
void ThirdPartyUseData(std::vector<Vector3> &vecVector3);
The obvious solution to this is to simply copy all of the data out of the vector<float> into the vector<Vector3>, but it seems like a waste. That memory is already in exactly the format is would be in when copied to the vector<Vector3>. I wonder if there is some way to re-construct the original vector<float> as a vector<Vector3>, without freeing all of that memory?