Search code examples
c++stringmfcatlwtl

Should I use CString, basic_string<TCHAR>, or something else with ATL/WTL?


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?


Solution

  • Something that I just read is that CString does not support null characters.

    I guess I'll keep with STL, then.