I keep receiving a C2664 conversion error in visual studio
It tells me that it can't convert parameter 1 from const std::string to std::string&. I tried adding/removing the const in the stringToWstring prototype and in the function itself and the error still comes up.
wstring hexval = buff.substr(buff.find(L"hex(2):"));
wstring h;
wchar_t ch;
typedef boost::tokenizer<boost::char_separator<wchar_t> > tokenizer;
boost::char_separator<wchar_t> sep(L"//,");
tokenizer tokens(hexval, sep);
for(tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); tok_iter++)
{
ch = someFunction(*tok_iter); //error here
h += ch;
}
wstring stringToWstring(const string& s)
{
wstring temp(s.length(), L'');
copy(s.begin(), s.end(), temp.begin());
return temp;
}
wchar_t someFunction(const wstring &hex_val)
{
}
Any ideas?
EDIT:
I see that this is really confusing so I'm going to explain a bit more..
Originally, what I wanted was these lines inside the for loop
ch = someFunction(*tok_iter);
h += ch
I also expected *tok_iter to return a wstring but I was getting an error like: cannot convert parameter 1 from const std::string to const std::wstring&
Because of that, I assumed that somehow, *tok_iter is a const std::string thus, I created a stringToWstring function to do the conversion. To do this in the for loop
ch = someFunction(stringToWstring(*tok_iter));
h += ch
When I did that, I got:
Error 1 error C2664: 'std::_String_const_iterator<_Elem,_Traits,_Alloc>::_String_const_iterator(const std::_String_const_iterator<_Elem,_Traits,_Alloc> &)' : cannot convert parameter 1 from 'std::_String_const_iterator<_Elem,_Traits,_Alloc>' to 'const std::_String_const_iterator<_Elem,_Traits,_Alloc> &' c:\program files\boost\boost_1_39\boost\tokenizer.hpp 63
I hope that's clearer now.