次のコードがありますが、コンパイルできません。 私は理由を考えることができません、拾い読みしてください。RapidJson kArrayType with String
rapidjson::Document jsonDoc;
jsonDoc.SetObject();
rapidjson::Document::AllocatorType& allocator = jsonDoc.GetAllocator();
rapidjson::Value messageArr(rapidjson::kArrayType);
std::string test = std::string("TEST");
messageArr.PushBack(test.c_str(), allocator);
以下のエラーが表示されます。
error: no matching function for call to ‘rapidjson::GenericValue >::PushBack(const char*, rapidjson::GenericDocument >::AllocatorType&)’
messageArr.PushBack(test.c_str(), allocator);
が完了 - RapidJosnは、文字列値の異なる種類があります。割り当てられた(必要があります。単純な 'const char *'ラッパー(範囲外になると壊れる)や短い文字列* 15 ch ars以下またはそれ以上のもの)。アロケータが必要だったので、コピーしたStrValueが必要だと仮定しました。 –