Given VS2010 SP1, I found that the <ostream> header has this overload for std::ostringstream and const char* :
template<class _Traits> inline basic_ostream<char, _Traits>& operator<<( basic_ostream<char, _Traits>& _Ostr, const char *_Val) { // insert NTBS into char stream ...
but there does not seem to be a similar overload for std::wostringstream and const wchar_t* .
If you add it to the source code, send CStringW using operator<< (my personal preference: use the CString::GetString() method with string streams and operator<< ):
namespace std { template<class _Traits> inline basic_ostream<wchar_t, _Traits>& operator<<( basic_ostream<wchar_t, _Traits>& _Ostr, const wchar_t *_Val) { ATLTRACE("It me, the new overload!\n"); typedef wchar_t _Elem; // // *** Copy and paste *** the source code from the following overload: // // template<class _Elem, // class _Traits> inline // basic_ostream<_Elem, _Traits>& operator<<( // basic_ostream<_Elem, _Traits>& _Ostr, const _Elem *_Val) // // // NOTE: I don't want to infringe any copyright. // // Moderators please delete the following lines if they // infringe any copyright. // typedef basic_ostream<_Elem, _Traits> _Myos; ios_base::iostate _State = ios_base::goodbit; streamsize _Count = (streamsize)_Traits::length(_Val); // may overflow streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count ? 0 : _Ostr.width() - _Count; const typename _Myos::sentry _Ok(_Ostr); if (!_Ok) _State |= ios_base::badbit; else { // state okay, insert _TRY_IO_BEGIN if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) for (; 0 < _Pad; --_Pad) // pad on left if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { // insertion failed, quit _State |= ios_base::badbit; break; } if (_State == ios_base::goodbit && _Ostr.rdbuf()->sputn(_Val, _Count) != _Count) _State |= ios_base::badbit; if (_State == ios_base::goodbit) for (; 0 < _Pad; --_Pad) // pad on right if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { // insertion failed, quit _State |= ios_base::badbit; break; } _Ostr.width(0); _CATCH_IO_(_Ostr) } _Ostr.setstate(_State); return (_Ostr); } } // namespace std
source share