考虑以下类:
当
class Foo
{
typedef bool (*filter_function)(Tree* node, std::list<std::string>& arg);
void filter(int filter, std::list<std::string>& args)
{
...
if (filter & FILTER_BY_EVENTS) {
do_filter(events_filter, args, false, filter & FILTER_NEGATION);
}
...
}
void do_filter(filter_function ff, std::list<std::string>& arg,
bool mark = false, bool negation = false, Tree* root = NULL)
{
...
}
bool events_filter(Tree* node, std::list<std::string>& arg)
{
...
}
};
当
events_filter
是 static
成员时,我可以将其作为参数传递给 do_filter
。但是我不想将它变成 static
。是否有一种方法可以将成员函数的指针传递给另一个函数?可能使用像 boost 库(如 function)之类的东西。
谢谢。