I'm, trying to use CPTL thread-pool for my application.
So, i have a function with this definition:
static void Invoke( int id, std::unique_ptr<BaseService> svc );
And tried to pass it to CPTL "push" method to be queued in thread-pool:
pThreadPool->push( std::ref(App::Invoke), std::move( svc ) );
But I received this error:
/home/hadi/CLionProjects/App/App.cpp:211:27: error: no matching member function for call to 'push'
pThreadPool->push( std::ref(App::Invoke), std::move( svc ) );
~~~~~~~~~~~~~^~~~
/home/hadi/CLionProjects/App/include/cptl/ctpl.h:152:14: note: candidate template ignored: substitution failure [with F = std::__1::reference_wrapper<void (int, std::__1::unique_ptr<BaseService, std::__1::default_delete<BaseService> >)>, Rest = <std::__1::unique_ptr<BaseService, std::__1::default_delete<BaseService> >>]: call to implicitly-deleted copy constructor of 'std::__1::unique_ptr<BaseService, std::__1::default_delete<BaseService> >'
auto push(F && f, Rest&&... rest) ->std::future<decltype(f(0, rest...))> {
^ ~~~~
/home/hadi/CLionProjects/App/include/cptl/ctpl.h:171:14: note: candidate function template not viable: requires single argument 'f', but 2 arguments were provided
auto push(F && f) ->std::future<decltype(f(0))> {
^
1 error generated.
Can anybody please tell me how to fix this ? Thanks.
Aucun commentaire:
Enregistrer un commentaire