I am trying to make a stl map with key as "KEYWORD" and value as "Class member function" But it is not getting compiled. Following is the code. Can anybody please let me know what is wrong. The class member functions are not static.
typedef void (RemoteHostManager::*CmdHandlerPtr)(char *);
typedef std::map<char *,CmdHandlerPtr> CommandHandlerSet;
typedef std::map<char *,CmdHandlerPtr>::iterator CommandHandlerSetItr;
void RemoteHostManager::InitializeCmdHandlerMap()
{
m_CommandSet["HELP"] = &RemoteHostManager::usage;
m_CommandSet["CONNECT"] = &RemoteHostManager::Connect;
m_CommandSet["READ"] = &RemoteHostManager::Read;
m_CommandSet["WRITE"] = &RemoteHostManager::Write;
m_CommandSet["STOP"] = &RemoteHostManager::Stop;
m_CommandSet["START"] = &RemoteHostManager::Start;
}
Following are the errors:
RemoteHostManager.cpp: In member function `void
RemoteHostManager::InitializeCmdHandlerMap()':
RemoteHostManager.cpp:14: no match for `std::_Rb_tree_iterator<std::pair<const
std::string, void (RemoteHostManager::*)(char*)>, std::pair<const
std::string, void (RemoteHostManager::*)(char*)>&, std::pair<const
std::string, void (RemoteHostManager::*)(char*)>*>& [const char[5]]'
operator
//similar error for other assignments!
m_CommandSet?.. and tell us line number corresponds to which piece of code.. by the way, have you changedchar*tostd::stringin the map?m_CommandSet? You posted a bunch of typedef's, yet the most important part - the declaration ofm_CommandSet- is missing.m_CommandSetis notCommandHandlerSet; it's ratherCommandHandlerSetItr.Am I right?