我有以下代碼:C++:tusing升壓unordered_map錯誤:沒有匹配的函數調用
結構STFRandomTreeFunction { 的typedef雙(* function_ptr)(常量STFDataPoint &數據,助推:: unordered_map & preloaded_images); };
struct STFRandomTreeFunctor
{
private:
boost::unordered_map<std::string, cv::Mat> *image_cache;
STFRandomTreeFunction::function_ptr function;
std::string function_id;
public:
STFRandomTreeFunctor(boost::unordered_map<std::string, cv::Mat>& cache, STFRandomTreeFunction::function_ptr function, std::string function_id)
:image_cache(&cache), function(function), function_id(function_id){}
std::string get_function_id(){
return function_id;
}
double operator()(const TrainingDataPoint& data_point){
return function(data_point, *image_cache);
}
};
unordered_map<string, STFRandomTreeFunctor> lut;
double a(const STFDataPoint& b, unordered_map<string, Mat>& c){
return 5;
}
int main(int argc, char* argv[]) {
unordered_map<string, Mat> cache;
lut["a"] = STFRandomTreeFunctor(cache, a, "a");
}
當我嘗試建立我得到以下錯誤:boost/unordered/detail/allocate.hpp:262:1: error: no matching function for call to ‘STFRandomTreeFunctor::STFRandomTreeFunctor()’
但我不知道爲什麼升壓試圖調用STFRandomTreeFunctor()
,這是因爲當我們創建空的映射,它試圖創建一個STFRandomTreeFunctor?如果是這樣,我該如何解決這個問題?
感謝
噢,對不起,我只是複製他們在錯誤的,結構是其中包含的頭文件實際上定義,我會編輯帖子以反映這一點 – Aly