George2 wrote:
I would like to learn some experiences about when should we use
std::basic_string and when should we use std::string?
I learned some Hello World level samples and now want to listen to
your practical experiences. :-)
I almost never had to use 'basic_string'. 'std::string' is a typedef
for 'std::basic_string<char ...>' (where ... represents some stuff
related to 'char'). If you deal with 'char', 'std::string' is enough.
If you deal with wide char ('wchar_t'), 'std::wstring' is the class.
I heard that Unicode is never well served by either of those, so folks
have their own custom classes for Unicode, I guess.
An example when I did have to use 'std::basic_string' is the library
where some functions were specialised for 'char' and 'wchar_t' (they
had to do that to use some non-overloaded functions) and just for the
completion's sake, I added a specialisation for 'unsigned char' and
'signed char' (since those are different from 'char'), and utilised
some casts internally.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask