I am working on compiling some old api code that was written back in mid to late 90's, it is written in C++98 and I am using GCC on linux.
I have this line of offending code:
UnpackCommunityData(data.insert(std::map<long, CommunityData>::value_type(ReadLong(), CommunityData())).first);
The above line leads to this error:
msg/Profile/SMsgProfileMsgs.cpp: In member function ‘virtual void WONMsg::SMsgProfile2DownloadCommunityTreeReply::Unpack()’:
msg/Profile/SMsgProfileMsgs.cpp:1410:107: error: cannot bind non-const lvalue reference of type ‘std::map<long int, WONMsg::CommunityData>::iterator&’ {aka ‘std::_Rb_tree_iterator<std::pair<const long int, WONMsg::CommunityData> >&’} to an rvalue of type ‘std::_Rb_tree_iterator<std::pair<const long int, WONMsg::CommunityData> >’
UnpackCommunityData(data.insert(std::map<long, CommunityData>::value_type(ReadLong(), CommunityData())).first);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
These are the definitions:
struct CommunityData {
long CommunitySeq;
long TrustLevelId;
std::wstring Name;
std::wstring Descr;
long JoinByInvitationOnly;
long ParentCommunitySeq;
std::vector<long> ChildrenSeq;
};
std::map<long, CommunityData> data;
void UnpackCommunityData(std::map<long, CommunityData>::iterator&);
void SMsgProfile2DownloadCommunityTreeReply::UnpackCommunityData(std::map<long, CommunityData>::iterator& itInfo) {
itInfo->second.CommunitySeq = itInfo->first;
itInfo->second.TrustLevelId = ReadLong();
ReadWString(itInfo->second.Name);
ReadWString(itInfo->second.Descr);
itInfo->second.JoinByInvitationOnly = ReadLong();
itInfo->second.ParentCommunitySeq = ReadLong();
unsigned short n = ReadShort();
for (int i = 0; i < n; ++i) itInfo->second.ChildrenSeq.push_back(ReadLong());
databyname.insert(std::map<std::wstring, long>::value_type(itInfo->second.Name, itInfo->second.CommunitySeq));
}
I'm not well versed in templates in C++, so I do not have a clue as to how to fix this error.
I would like it if someone could walk me through the error and solution.
Aucun commentaire:
Enregistrer un commentaire