0
我已经写了下面的模板成员函数,但我不能把它而不被编译器收到错误:模板成员函数的错误:铛不匹配任何成员函数
template <class T, class A>
auto tpool::enqueue(T&& func, std::vector<A>&& args)
-> std::vector<std::future<decltype(std::forward<T>(func)(decltype(std::forward<A(args))::value_type))>>
{
//...
}
tpool tp();
auto f = [] (int) { /* ... */ };
std::vector<int> args;
tp.enqueue(f, args);
我得到以下错误通过铛:
test_cpp.cpp:144:5: error: no matching member function for call to 'enqueue'
tp.enqueue(f, args);
test_cpp.cpp:107:13: note: candidate template ignored: substitution failure [with T = <lambda at test_cpp.cpp:140:11> &, A = int]: no matching function for call to 'forward'
auto tpool::enqueue(T&& func, std::vector<A>&& args)
通过'tpool tp();'你的意思是'tpool tp;'? – kennytm
你有几个语法错误。例如,'std :: forward stardust