我已经编写了以下模板成员函数,但我无法在编译器出错的情况下调用它:
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)