我有一个带有以下方法的线程管理器类:
template <class _Fn, class... _Args>
void create_thread (_Fn&& fun, _Args&&... args)
{
std::thread t (std::mem_fn(&MyClass::threads_entry<_Fn, _Args...>),
this, fun, args...);
}
template <class _Fn, class... _Args>
void threads_entry (_Fn&& fun, _Args&&... args)
{
fun (std::forward <_Args>(args)...);
perform_on_before_thread_exit_tasks();
}
在另一堂课中,我正在尝试使用它。这个类有以下成员:
void make_sure_thread_created ()
{
m_threads.create_thread (
&MyClass2::thread_tasks,
this);
}
void thread_tasks ()
{
}
我收到编译错误(MS VC2013):
error: C2064: term does not evaluate to a function taking 1 arguments
它指向这行代码:
fun (std::forward <_Args>(args)...);
难道我做错了什么?或者它是编译器错误?在这里可以做什么?...