如何在 C++ 中插入 protobuf 映射?

Rai*_*ose 3 c++ protocol-buffers

对于以下Map无法插入到Map中

map<string, double> doubleProps = 4;
map<string, int32> intProps = 5;
map<string,string> stringProps=6;
Run Code Online (Sandbox Code Playgroud)

以下是我尝试过的,但它不起作用

doubleProps["key"]="value" //doesn't work
*(doubleProps["key"]).insert("value") //doesn't work
doubleProps.insert("key","value")
Run Code Online (Sandbox Code Playgroud)

gul*_*uly 7

这是在c ++中插入protobuf对象中的映射的方法

(*mutable_stringprops())["key"]=value
Run Code Online (Sandbox Code Playgroud)

https://developers.google.com/protocol-buffers/docs/reference/cpp- generated#map-fields