You are using signature
to search the map, but then using message
to retrieve a member pointer from the map. If signature
and message
are not the same value, you will not get the pointer you are expecting, maybe even a NULL pointer if the message
value does not exist in the map yet. You need to use signature
again when retrieving the pointer. Better, since you have already performed the search once, you should use the result of the search instead of invoking the []
operator to perform the same search again a second time.
Try this:
typedef string (ServerControl::*VectorArgMember)(vector<string>);
map<string, VectorArgMember> functionMap;
.
map<string, VectorArgMember>::iterator i = functionMap.find( signature );
if (i != functionMap.end())
{
VectorArgMember memberPtr = i->second;
return (this->*memberPtr)(arguments);
}