My question is similar to this, except that I'm dealing with wstring
rather than string
. I switched the types to wstring
and wchar_t
and compiled it but I'm getting an error. This is the code:
int delete_punc(std::wstring& str)
{
wchar_t* chars = L".,!?";
for (int i = 0; i < sizeof(chars); i++)
str.erase(std::remove(str.begin(), str.end(), chars[i]), str.end());
return 0;
}
This is the error that I get:
error: cannot convert ‘std::basic_string<wchar_t>::iterator
{aka __gnu_cxx::__normal_iterator<wchar_t*, std::basic_string<wchar_t> >}’
to ‘const char*’ for argument ‘1’ to ‘int remove(const char*)
Edit: I also tried other brute force variants. Both returned the same error.
int delete_punc(std::wstring& str)
{
//str.erase(std::remove(str.begin(), str.end(), L"."), str.end());
//str.erase(std::remove(str.begin(), str.end(), "."), str.end());
return 0;
}