casablanca ライブラリを使用して json 値をシリアル化しています。
typedef std::wstring string_t
これを使用して std::string への変換を試み、wstring から string に変換しました。コンパイルは問題ありませんが、リターン行を実行するとプログラムがクラッシュします。
std::string getString()
{
web::json::value cvalue;
/* ----- code ----- */
typedef std::wstring string_t;
string_t outputString = cvalue.serialize();
typedef std::codecvt_utf8<wchar_t> convert_type;
std::wstring_convert<convert_type, wchar_t> converter;
std::string converted_str = converter.to_bytes(outputString);
return converted_str;
}
なぜこれがクラッシュしているのか理解できません。以下は、その関数を呼び出す行です。
std::string s = getString();
free(_Ptr)
プログラムは、xdebug というファイルの行でブレーク ポイントをトリガーしました。ここで言っていることがよくわかりません。これがあなたのために物事を明確にするのに役立つことを願っています.
template<class _Ty>
void __CLRCALL_OR_CDECL _DebugHeapDelete(_Ty *_Ptr)
{ // delete from the debug CRT heap even if operator delete exists
if (_Ptr != 0)
{ // worth deleting
_Ptr->~_Ty();
// delete as _NORMAL_BLOCK, not _CRT_BLOCK, since we might have
// facets allocated by normal new.
free(_Ptr);
}
}
ありがとう!