By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,849 Members | 2,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,849 IT Pros & Developers. It's quick & easy.

regarding WString

P: 1
Hi friends,
The following snippet works fine with C++ compilation whereas it fails when I compile in linux. The function toWString returns a WString.

template<class T> const wstring toWString(T t)
{
std::wstringstream ws;
ws << t;
return ws.str();
}

When I call like
int t;
toWString(t).c_str();
the code fails giving an error in linux-- cannot convert basic string stream to a non-scalar type wheras it compiles fine with C++.

Could someone help me regarding this ?
thanks a lot.
Oct 15 '07 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
I'm not sure what you are trying to do here. But a wstringstream uses only wchar_t and a stringstream uses only a char.

I don't think your template type T is going to work unless: T is wchar_t or is a conversion operator of your struct/class for wchar_t.

And even then, the Unicode issue is not resolved.
Oct 15 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.