Rapidjson ドキュメントをメンバー変数として使用し、これを行うと、次のようになります。
class Test
{
rapidjson::Document m_jsonDocument;
public:
void f()
{
// WORKS FINE
rapidjson::Document document;
if (document.Parse<0>("{ \"hello\" : \"world\" }").HasParseError())
printf("ERROR PARSING JSON\n");
else
printf("%s\n", document["hello"].GetString());
// BUT HERE THROWS, WHY?
if (m_jsonDocument.Parse<0>("{ \"hello\" : \"world\" }").HasParseError())
printf("ERROR PARSING JSON\n");
else
printf("%s\n", m_jsonDocument["hello"].GetString());
}
};
CTORでオンラインでif (m_jsonDocument.Parse<0>("{ \"hello\" : \"world\" }").HasParseError())
アプリを呼び出すと、クラッシュします。Visual Studio デバッガーは、"メモリを読み取れません" と表示されます。のために。何が問題ですか?メンバー変数とローカル変数の違いは何ですか?flags_ = defaultFlags[type];
document.h
GenericValue(Type type)
_flags
編集:f
defined here を使用してコールバックとして設定し、 setResponseCallback
defined hereを使用f
してコールバックとして呼び出されています 。dispatchResponseCallbacks