I have below code works fine in visual studio 2005. But get compile errors when migrating to visual studio 2013.
// Check if the row in the file starts with a double value
bool RowReader::isDouble(std::wstring value)
{
double testValue;
std::wistringstream in(value);
in.setf(std::ios::dec, std::ios::basefield);
if((in >> testValue) == NULL)
return false;
return true;
}
The error is:
Error 1 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::basic_istream<wchar_t,std::char_traits<wchar_t>>' (or there is no acceptable conversion)
Any help ? I am very new to this. 1. Is testValue initial value 0 ? 2. Why if it's equal to NULL if the first character is not double ? 3. How to fix this compile error?
Problem solved. See below code:
bool isDouble(std::wstring value)
{
wchar_t * endptr = 0;
wcstod(value.c_str(), &endptr);
if (*endptr != '\0' || endptr == value.c_str()){
return false;
}
return true;
}