c++ - 为什么/如何将非宽字符串传递给 wstringstream::operator<<?

标签 c++ visual-c++ stl

wstring ss;
ss << L"Some wide-char text" << " and some non-wide-char text";

这似乎工作得很好,但为什么当 char_type 不是 char 时呢?

最佳答案

无论模板的 CharT 是什么,所有流都有 char 的重载。

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 );

关于c++ - 为什么/如何将非宽字符串传递给 wstringstream::operator<<?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27778312/

相关文章:

c++ - 是否有可能在编译时强制两个派生类总是为覆盖函数返回不同的值?

c++ - 如何使用 STL 和/或 Boost 在 C++ 中模拟 SQL 连接

c++ - 为什么 std::set 是关联容器

c++ - 将 float 转换为 32 位十六进制 C++

c++ - Visual Studio 2012 更新 2 中的 std::async 衰减(丢失)右值引用。任何解决方法?

c++ - 我可以将 std::begin 和 std::end 专门化为 equal_range() 的返回值吗?

c++ - Openmp线程休眠

c++ - 在不编辑主 dll 的情况下覆盖另一个 dll 中的函数

c++ - 具有私有(private)成员的结构的构造函数

c# - QT 文件与 Visual Studio