I have a function that parses a .csv file and tokenizes each line using a "," as the delimiter. I tokenize it into a vector. I then iterate over that vector and convert each string to a number using a template function. For some reason this works great in all but once compile configuration. I do not know the details of the configrations as they are set up by a different department. I'm hoping you guys see something glaringly wrong with what I've done here and can solve this.
Here is the iteration in question:
vector<std::string> tokens;
tokens = string_split(line);
std::vector<std::string>::iterator it;
for(it = tokens.begin(); it != tokens.end(); it++) {
int i = 0;
from_string<int>(i,*it,std::dec);
if(i != SYS_ELEC_BATTERY_VERSION) {
SysLoggerMessage("Battery Data does not match this version of the battery model!", MESSAGE_TYPE_ERROR);
return;
}
}
So at the point just before the the from_string call, *it is "3". However, when I step into the from_string function:
template <class T>
bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&))
{
std::istringstream iss(s);
return !(iss >> f >> t).fail();
}
When stepping into the from_string, s is a BadPtr. Why this works with no problem in some configurations and not in one, I do not know. Any ideas?
Thanks in advance!