提问者:小点点

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


对于无法插入到映射中的下列映射

map<string, double> doubleProps = 4;
map<string, int32> intProps = 5;
map<string,string> stringProps=6;

下面是我尝试过的,但是没有用

doubleProps["key"]="value" //doesn't work
*(doubleProps["key"]).insert("value") //doesn't work
doubleProps.insert("key","value")

共1个答案

匿名用户

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

(*mutable_stringprops())["key"]=value

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

相关问题


MySQL Query : SELECT * FROM v9_ask_question WHERE 1=1 AND question regexp '(何在|c++|中|插入|protobuf|映射)' ORDER BY qid DESC LIMIT 20
MySQL Error : Got error 'repetition-operator operand invalid' from regexp
MySQL Errno : 1139
Message : Got error 'repetition-operator operand invalid' from regexp
Need Help?