Closed atari83 closed 1 year ago
Hello there,
So, i have a function with this definition: static void Invoke( int id, std::unique_ptr<BaseService> svc );
static void Invoke( int id, std::unique_ptr<BaseService> svc );
And tried to pass it to ctpl "push" method to be queued in thread-pool: pThreadPool->push( std::ref(App::Invoke), std::move( svc ) );
pThreadPool->push( std::ref(App::Invoke), std::move( svc ) );
But I get 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.
you could change function's definition(pass by reference):
static void Invoke( int id, std::unique_ptr<BaseService> &svc );
and try
pThreadPool->push(App::Invoke, std::move(svc));
Hello there,
So, i have a function with this definition:
static void Invoke( int id, std::unique_ptr<BaseService> svc );
And tried to pass it to ctpl "push" method to be queued in thread-pool:
pThreadPool->push( std::ref(App::Invoke), std::move( svc ) );
But I get this error: