Page 1 of 1

Rev 2323, linux compile fails

Posted: Tue Dec 03, 2013 10:48 am
by John Adams
Again, Windows is being forgiving where Linux is not.
zoneserver.cpp:5186: error: no match for ‘operator=’ in ‘itr = ((ZoneServer*)this)->ZoneServer::m_timedActions.std::map<_Key, _Tp, _Compare, _Alloc>::erase [with _Key = TimedAction*, _Tp = unsigned int, _Compare = std::less<TimedAction*>, _Alloc = std::allocator<std::pair<TimedAction* const, unsigned int> >](itr)’
/usr/include/c++/4.4/bits/stl_tree.h:154: note: candidates are: std::_Rb_tree_iterator<std::pair<TimedAction* const,
unsigned int> >& std::_Rb_tree_iterator<std::pair<TimedAction* const, unsigned int> >::operator=(const std::_Rb_tree_iterator<std::pair<TimedAction* const, unsigned int> >&)

Re: Rev 2323, linux compile fails

Posted: Tue Dec 03, 2013 1:30 pm
by Jabantiz
iterator doesn't have a '=' operator??? I swear I have used erase like this before without issue, will look into this.

Re: Rev 2323, linux compile fails

Posted: Tue Dec 03, 2013 6:16 pm
by Jabantiz
added #include <map> to zoneserver.cpp, hopefully that will fix the issue.

Re: Rev 2323, linux compile fails

Posted: Tue Dec 03, 2013 6:22 pm
by Jabantiz
Jabantiz wrote:added #include <map> to zoneserver.cpp, hopefully that will fix the issue.
Actually nm that won't change anything as the header file already had that, going to revert that change.

And I think I found the actual problem, erase will return an iterator (the way I am using it) in c++ 11, earlier version return a void.
http://www.cplusplus.com/reference/map/map/erase/
so it depends what version of c++ your compiler uses.

Not sure how to handle this now...

Re: Rev 2323, linux compile fails

Posted: Wed Dec 04, 2013 11:03 am
by John Adams
Jabantiz wrote:Not sure how to handle this now...
Scat says he's on it, since it's a linux issue I asked him to look into it.

Stand by, Jab.

Edit: From Scat -
give the code on svn a try. basically you need 2 iterators. when you find an element you need to delete, you set the delete iterator to the looping iterator, then increment the looping iterator, then delete from the map where the delete iterator itr.

old code: itr = map.erase(itr);

new code: itr_delete = itr++; map.erase(itr_delete);
Make sense?