我想在单独的线程上运行模板函数,但IntelliSense(VC++ 2010 Express)不断给我提供错误: “错误:没有构造函数的实例”boost :: thread ::螺纹 “参数列表匹配”,如果我尝试编译我得到这个错误: ‘错误C2661:‘提高::螺纹::线程’:没有重载函数有5个参数’boost ::线程和模板函数
只发生错误因为我添加了模板,所以我确定它与它们有关,但我不知道是什么。
的我传递来提高::线程的两个参数是模板函数定义为:
template<class F>
void perform_test(int* current, int num_tests, F func, std::vector<std::pair<int, int>>* results);
和:
namespace Sort
{
template<class RandomAccessIterator>
void quick(RandomAccessIterator begin, RandomAccessIterator end);
} //namespace Sort
我打电话的boost ::线程像这样:
std::vector<std::pair<int, int>> quick_results;
int current = 0, num_tests = 30;
boost::thread test_thread(perform_test, ¤t, num_tests, Sort::quick, &quick_results);
完美,谢谢。 – Rarge 2010-11-01 16:26:50