You can use a string
instead of a stream:
void showUsage(std::wstring oErrortext, bool bExit, int nExitCode)
{
if (!oErrortext.empty())
std::wcerr << oErrortext << std::endl;
...
}
To use it, concatenate strings with +
:
showUsage(std::wstring(L"Number format missing -") + oParam->mOption, true, 10);
My system has an incompatible return type for operator<<
of stringstream
(it returns a reference to ostream
, not a reference to stringstream
), so it's impossible to append stuff to a stringstream
and send it to a function in a single line of code (it might be possible to use a static_cast
, but you certainly don't want this ugly hack). So, unless this is an implementation bug (unlikely!), you must do large changes your code, like suggested above.