I have C++ class which is template. it have member function which should take any lamda as parameter;
basically this is what I wanna do:-
#include <QFuture>
#include <QFutureWatcher>
template <class T>
class EFuture {
private:
QFuture<T> future;
QFutureWatcher<T> watcher;
public:
explicit EFuture(QFuture<T> &future);
void onFinished(void (*f)() );
};
template <class T>
EFuture<T>::EFuture(QFuture<T> &future ): future(future)
{ }
template<class T>
void EFuture<T>::onFinished(void (*f)()){
QObject::connect(watcher,&QFutureWatcher<T>::finished,f);
watcher.setFuture(future);
}
This have serious restriction as I can't capture anything in lambda which I am passing. where I try to do something like this:-
future->onFinished([someobject](){
...
});
I get following error:-
connectionworker.cpp:106:24: error: no viable conversion from '(lambda at /home/noone/Development/Exatation/Exever/src/connectionworker.cpp:106:24)' to 'void (*)()'
efuture.h:17:28: note: passing argument to parameter 'f' here
Aucun commentaire:
Enregistrer un commentaire