I am trying to write a template function which will extract the value of the given datatype from the given string. I came up with something like this:
template<class T>
static T getValue(const CString& val_in)
{
std::wstring value = val_in;
std::istringstream iss;
iss.str(value);
T val = T();
iss>>val;
return val;
}
But this gives the following error for the iss.str(value)
statement.
error C2664: 'void std::basic_istringstream<_Elem,_Traits,_Alloc>::str(const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'std::wstring' to 'const std::basic_string<_Elem,_Traits,_Ax> &'
So basically, std::istringstream
is accepting only std::string
. I thought there may be a std::wistringstream
but there doesn't seem to be one available. Any clues how can I do it?