P
Pierre Barbier de Reuille
Hi,
I was wondering why there was no predefine operator<< puting a
std::string into a std::wostream. The strangest is that something
similar to this would work:
std::wostream& operator<<(std::wostream& stream, std::string str)
{
stream << str.c_str();
return stream;
}
The only problem with this solution is it invalidate the different
iterators you have on the string (because of the call to c_str), while
the operator<< should not do that.
Thanks,
Pierre
I was wondering why there was no predefine operator<< puting a
std::string into a std::wostream. The strangest is that something
similar to this would work:
std::wostream& operator<<(std::wostream& stream, std::string str)
{
stream << str.c_str();
return stream;
}
The only problem with this solution is it invalidate the different
iterators you have on the string (because of the call to c_str), while
the operator<< should not do that.
Thanks,
Pierre