Forum Chat


Mar23,13:31 Johan Marechal
Wees gegroet
Sep20,17:50 Vicente Duque
Kim, Martin, Others :...
Jul07,11:10 Johan Marechal
PGP 9
Jul05,21:13 martin
Fastest in the bush
Jul05,07:48 martin
Spamdexing
Jun28,21:16 martin
New domain / new blog!
Jun28,21:11 martin
On posting etiquette

Remembering C++ stream operators

Comment on this article

Getting the syntax right when overloading stream operators isn't easy. If you take the simplest way, you'll soon discover the operator isn't found for streams like wstringstream. Actually, the most common stream operator prototypes don't  catch 16-bit character streams. The right stuff I found in Josuttis book, and it looks like:

template <class charT, class traits> inline
std::basic_ostream<charT,traits>& operator<<(std::basic_ostream<charT,traits>& strm, const QDate& qd)
{
	wstring wstrDate;
	qd.date2String(&wstrDate);
	strm << wstrDate.c_str();
	return strm;
}

I've greyed out the stuff that isn't universal in the example above. Have fun!

Comment on this article

TOP