Wywołanie wskaźnika funkcji członka przechowywanego na mapie standardowej
Przechowuję mapę w klasie, która ma łańcuchy jako klucze i wskaźniki do funkcji składowych jako wartości. Mam problem z wywołaniem odpowiedniej funkcji rzuć wskaźnik funkcji. Oto kod:
#include <iostream>
#include <string>
#include <map>
using namespace std;
class Preprocessor;
typedef void (Preprocessor::*function)();
class Preprocessor
{
public:
Preprocessor();
~Preprocessor();
void processing(const string before_processing);
private:
void take_new_key();
map<string, function> srch_keys;
string after_processing;
};
Preprocessor::Preprocessor()
{
srch_keys.insert(pair<string, function>(string("#define"), &Preprocessor::take_new_key));
}
Preprocessor::~Preprocessor()
{
}
void Preprocessor::processing(const string before_processing)
{
map<string, function>::iterator result = srch_keys.find("#define");
if(result != srch_keys.end())
result->second;
}
void Preprocessor::take_new_key()
{
cout << "enters here";
}
int main()
{
Preprocessor pre;
pre.processing(string("...word #define other word"));
return 0;
}
W działaniuPreprocessor::processing
jeśli łańcuch zostanie znaleziony na mapie, wywołam odpowiednią funkcję. Problem polega na tym, że w tym kodziePreprocessor::take_new_key
nigdy nie jest nazywany.
Gdzie jest błąd?
Dzięki