c++ - STL SET Iterator assignment no viable candidate -


i have c++ program using stl set iterator. set , iterator defined as:

 set<tokentableentry*, comparator> _xclitokentable;   set<tokentableentry*>::const_iterator it; 

i have routine called findtoken (shown below), has statement:

 = _xclitokentable.find(_tokentableentry); 

which producing error message:

"implicit std::_tree std::less,std::allocator,0>>::const_iterator::operator=(const std::_tree,std::allocator,0>>::const_iterator &)" not viable candidate.

i have no idea message telling me or how correct it. can make suggestion?

thanks help.

john

int xclitokentable::findtoken (string name,  tokentableentry *_tokentableentry)  {      int type;     type = -1;      string lookupname(name);      std::transform(name.begin(), name.end(), name.begin(), ::tolower);      _tokentableentry->name = lookupname;      **it = _xclitokentable.find(_tokentableentry);**      if (it != _xclitokentable.end())     {         if ((*it)->name == name)         {             type = (*it)->type;             tokencount++;             *_tokentableentry = *(*it);             return type;         }      }     return type; } 

you should declare it as

set<tokentableentry*, comparator>::const_iterator it; 

or can use auto if c++11 available:

auto = _xclitokentable.find(_tokentableentry); 

(and preferrably declare int xclitokentable::findtoken(...) const, return type of find const_iterator)


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -