我做了一些事情來打破我的程序中的功能,但我無法弄清楚什麼。我在一類headerfile定義一個typedef:C++助推功能問題
typedef boost::function<void(instr_ptr, std::vector<ResultBase*>) > GenFunction;
而那類裏面我有兩個實例:
GenFunction Gen;
GenFunction Kill
我將它們設置如下:
void DataFlowSolver::SetGenFunction(GenFunction &func)
{
Gen = func;
}
void DataFlowSolver::SetKillFunction(GenFunction &func)
{
Kill = func;
}
我在另一個函數一個單獨的頭文件:
void GenLiveVar(const instr_ptr instr, std::vector<ResultBase*> &list);
我創建DataFlowSolver類的實例,並試圖分配到它,如下所示:
blockSolver.SetGenFunction(GenLiveVar);
然而,編譯器會抱怨:
CFG.cc:617: error: no matching function for call to 'DataFlowSolver::SetGenFunction(void (&)(instr_ptr, std::vector >&))' DataFlowSolver.h:21: note: candidates are: void DataFlowSolver::SetGenFunction(GenFunction&)
但它讓我做到這一點:
GenFunction fun = GenLiveVar;
blockSolver.SetGenFunction(fun);
任何人有一個想法可能是錯的什麼?我知道這工作之前,但我不知道我是如何設法打破它...