クラスのメンバ関数をstd :: functionに代入しようとしましたが、コンパイル時にエラーが発生しますfunction template 'unknown type std ::呼び出す(_Callable & &、_TYPES & & ...)以下別のクラスのメンバ関数を渡そうとするときに「関数テンプレートを特殊化できませんでした」
そのクラスのヘッダファイルである:以下
class TypeAnalysis {
public:
bool AnalysisHelper(std::string filePath);
void createTypeTable(std::string dir, std::string pattern, size_t nThread = 3);
std::vector<std::string> getFiles(std::string dir, std::vector<std::string> patterns);
private:
};
そして、私が割り当てていますcreatetypeTable機能ですAnalysisHelperメソッドを標準:: fnuctionオブジェクトに変換します。
void TypeAnalysis::createTypeTable(std::string dir, std::string pattern, size_t nThread)
{
Threadpool<bool, std::string> tp(10);
DataContext dc;
tp.start();
std::vector<std::string> patterns = SH::split(pattern);
std::vector<std::string> files = getFiles(dir, patterns);
std::function<bool(std::string)> w = &TypeAnalysis::AnalysisHelper; //I think issue is here
try {
if (files.size() > 0) {
for (size_t i = 0; i < files.size(); i++) {
WorkItem<bool, std::string> *wi1 = new WorkItem<bool, std::string>(&w, &files[i]);
tp.doWork(wi1);
}
}
}
catch (std::exception ex) {
std::cout << ex.what();
return;
}
tp.doWork(nullptr);
tp.wait();
DataContext::getContextThreadPool().doWork(nullptr);
}
私は任意のクラス定義せずに同じことをしようとした
、それがうまく働いた(AnalysisHelperはGlabal関数であったとの主はcreateTypeTableと同じ体を持っていました)。何が間違っていますか?