title: C++, conversion from utility:string_t to std::string crashes on return
body: <p>I am using casablanca library to serialize json values.</p>
  
  <p>I tried making a conversion to std::string using <code>typedef std::wstring string_t</code> and <a href="https://stackoverflow.com/questions/4804298/how-to-convert-wstring-into-string/18374698#18374698">this to convert from wstring to string</a>. It's compiling fine but the program just crashes when executing the return line.</p>
  
  <pre><code>std::string getString()
  {
      web::json::value cvalue;
      /* ----- code ----- */
      typedef std::wstring string_t;
      string_t outputString = cvalue.serialize();
  
      typedef std::codecvt_utf8&lt;wchar_t&gt; convert_type;
      std::wstring_convert&lt;convert_type, wchar_t&gt; converter;
      std::string converted_str = converter.to_bytes(outputString);
  
      return converted_str;
  }
  </code></pre>
  
  <p>I can't understand why this is crashing. Below is the line calling that function.</p>
  
  <pre><code>std::string s = getString();
  </code></pre>
  
  <p>The program triggered a break point here at line <code>free(_Ptr)</code> in a file called xdebug. I don't really understand what it's saying here. Hope this helps clarify things for you.</p>
  
  <pre><code>template&lt;class _Ty&gt;
      void __CLRCALL_OR_CDECL _DebugHeapDelete(_Ty *_Ptr)
      {   // delete from the debug CRT heap even if operator delete exists
      if (_Ptr != 0)
          {   // worth deleting
          _Ptr-&gt;~_Ty();
          // delete as _NORMAL_BLOCK, not _CRT_BLOCK, since we might have
          // facets allocated by normal new.
          free(_Ptr);
          }
      }
  </code></pre>
  
  <p>Thanks!</p>