Reputation: 63710
wstring ss;
ss << L"Some wide-char text" << " and some non-wide-char text";
This appears to work just fine but why, when char_type
is not char
?
Upvotes: 1
Views: 92
Reputation: 385088
Because it is.
Exactly
std::char_traits<char>::length(s)
characters are inserted.
Before insertion, first, all characters are widened usingos.widen()
.
(source)
Upvotes: 0
Reputation: 20990
All streams have overloads for char
, regardless of the CharT
of the template.
http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt2
template< class CharT, class Traits >
basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os,
const char* s );
Upvotes: 1