重温了一下 Effective C++,发现这就是条款24所指出的问题,看来读书百遍不如写代码一遍啊
#ifdef _UNICODE typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > string_t; #else typedef std::basic_string<char, std::char_traits<char>, std::allocator<char> > string_t; #endif
不过我喜欢更简短的定义:
#ifdef _UNICODE typedef std::wstring string_t; #else typedef std::string string_t; #endif
下面是我常用的Unicode定义:
#include <string> #include <sstream> namespace duilib { #ifdef _UNICODE typedef wchar_t char_t; typedef std::wstring string_t; typedef std::wstringstream stringstream_t; #else typedef char char_t; typedef std::string string_t; typedef std::stringstream stringstream_t; #endif }
原文:http://www.cnblogs.com/Alberl/p/3344886.html
2 CDuiString的bug,布布扣,bubuko.com
原文:http://www.cnblogs.com/a9999/p/3799252.html