Reputation: 210445
I've only learned a little bit of ATL in the last couple of days (after realizing how much pain pure Win32 is) and also learned about WTL and MFC, and from what I see, there are quite a few different string classes available for me.
I used to do something like this:
#include <tchar.h>
#include <string>
namespace std { typedef basic_string<TCHAR> _tstring; }
and then use _tstring
everywhere in my code. After learning some ATL, I learned that there's a CString
class in atltmp.h
. Apparently, there's another CString
class in WTL, and yet another CString
class in MFC.
I have no idea whether I will stick with ATL or whether I'll switch to WTL, MFC, or something else. But right now, I'm in the process of converting my Win32 code to ATL, and I'm not sure what to change and what to keep.
Should I make my strings use CString
instead of _tstring
? Is there any benefit in doing so, considering both executable size (excluding shared libraries) and portability/compatibility?
Upvotes: 4
Views: 1448
Reputation: 210445
Something that I just read is that CString
does not support null characters.
I guess I'll keep with STL, then.
Upvotes: 0
Reputation: 109119
My preference would be to stick with CString
for ATL / MFC / WTL. It's not like you have much of an option for portability if you're using those frameworks anyway; and you know what they say: When in Rome ...
Also, CString
does have a few niceties about it
CString::LoadString
CString::GetBuffer/ReleaseBuffer
CStringA
& CStringW
printf
-like formatting using CString::Format
Upvotes: 6