title: How do you convert CString and std::string std::wstring to each other?
body: <p><code>CString</code> is quite handy, while <code>std::string</code> is more compatible with STL container. I am using <code>hash_map</code>. However, <code>hash_map</code> does not support <code>CString</code>s as keys, so I want to convert the <code>CString</code> into a <code>std::string</code>.</p>
  <p>Writing a <code>CString</code> hash function seems to take a lot of time.</p>
  <pre><code>CString -----&gt; std::string
  </code></pre>
  <p>How can I do this?</p>
  <pre><code>std::string -----&gt; CString:
  
  inline CString toCString(std::string const&amp; str)
  {
      return CString(str.c_str()); 
  }
  </code></pre>
  <p>Am I right?</p>
  <hr />
  <p><strong>EDIT:</strong></p>
  <p>Here are more questions:</p>
  <p>How can I convert from <code>wstring</code> to <code>CString</code> and vice versa?</p>
  <pre><code>// wstring -&gt; CString
  std::wstring src;
  CString result(src.c_str());
  
  // CString -&gt; wstring
  CString src;
  std::wstring des(src.GetString());
  </code></pre>
  <p>Is there any problem with this?</p>
  <p>Additionally, how can I convert from <code>std::wstring</code> to <code>std::string</code> and vice versa?</p>