Value使用错误

大家好,我在程序中使用Value,同样的代码在win32平台编译正常。
在Android上编译通不过,请大家多多指点,谢谢。

代码如下:
rapidjson::Value instance(rapidjson::kObjectType);
instance.AddMember(“id”, getId(), allocator); //getId() 返回一个int型

报错信息:
jni/…/…/cocos2d/external\json/document.h:292:16: error: call to constructor of ‘rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >’ is ambiguous
GenericValue v(value);
^ ~~~~~
jni/…/…/Classes/Message/TLInstance.cpp:71:11: note: in instantiation of function template specialization ‘rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >::AddMember’ requested here
instance.AddMember(“id”, getId(), allocator);
^

看下GenericValue的构造函数,有没个不同类型的参数就只支持那几种,其它的不行,至少我遇见时这样的情况:10:

谢谢,我这个更奇葩,函数的返回值是rapidjson::Value改成rapidjson::Value&,问题就解决了

亲 遇到和你一样的问题了 你在哪里加的&

这个问题不是奇葩,是特意为之。 加上&返回Value引用就可以用了