So I have a computationally heavy c++ function that extracts numbers from a file and puts them into a vector. When I run this function in main, it takes a lot of time. Is it possible to somehow have this function computed once, and then linked to the main program so I can save precious computation time in my main program every time I try to run it?
The function I have is this:
vector <double> extract (vector <double> foo)
{
ifstream wlm;
wlm.open("wlm.dat");
if(wlm.is_open())
{
while (!wlm.eof())
{
//blah blah extraction stuff
}
return foo;
}
else
cout<<"File didn't open"<<endl;
wlm.close();
}
And my main program has other stuff which I compute over there. I don't want to call this function from the main program because it will take a long time. Instead I want the vector to be extracted beforehand during compile time so I can use the extracted vector later in my main program. Is this possible?