I am creating threadsafe list and i got a problem with calling thread constructor. I got a template class
template <typename T>
class mylist{...}
that stores nodes with T data and mylist
got member function defined like this
template <typename FUNC>
void for_each(FUNC f){...}
that calls f() for every T data in the list. I also got function
template<typename T>
void show(T data)
{cout<<data<<", ";}
My problem is that I don't know how to make thread and pass this function to it.
I tried like this (mylist
is a class name,multithreadlist
is an object of mylist<size_t>
std::thread t1(&mylist<size_t>::for_each<void(*)(size_t)>, &multithreadlist, show<size_t>);
and i get C2893 Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...)' and C2672 'std::invoke': no matching overloaded function found