CString
is quite handy, while std::string
is more compatible with STL container.
I am using hash_map
. However, hash_map
does not support CString
as key, so I want to convert CString
into std::string
.
Writing a CString
hash function seems to take a lot of time.
CString -----> std::string
How can I do this?
std::string -----> CString:
inline CString toCString(std::string const& str)
{
return CString(str.c_str());
}
Am I right?
EDIT:
Here are more questions:
How can I convert wstring
, CString
to each other?
//wstring -> CString,
std::wstring src;
CString result(src.c_str());
//CString->wstring.
CString src;
::std::wstring des(src.GetString());
Is there any problem?
How can I convert std::wstring
, std::string
to each other?