I like that. I do define both, but your suggestion strikes me as more
elegant. Thanks.
namespace std {
#if defined _UNICODE || defined UNICODE
typedef wstring tstring;
typedef wstringstream tstringstream;
#else
typedef string tstring;
typedef stringstream tstringstream;
#endif
}
If you do this it does not mean that the CString
and std::string will use the same string types.
_UNICODE controls the CRT functions, UNICODE
controls the Win32 API (and MFC).
So if you have _UNICODE defined, but not UNICODE,
then tstring will be Unicode ans CString will be ANSI.
This is why one should *always* define both
(or it means they are asking for rouble :-)
A cleaner option (kind of equivalent to the one above) is:
namespace std {
typedef basic_string<_TCHAR> tstring;
typedef basic_stringstream<_TCHAR> tstringstream;
}
_TCHAR follows the _UNICODE definition.
If you want to be in sync with CString, then you should use TCHAR