I made a class GUI
which had some member functions, and I tried to call an async function by following this link.
So in the main function, I made a pointer to a class and initialized it as follows:
GUI *g = new GUI(false);
message *buffer;
bool *done;
vector<message> msg;
vector<userLastSeen> reg_users;
// some initializations of the vectors msg, reg_users
auto f = async(&GUI::mainLoop, g, (&msg), (®_users), (buffer), (done));
f.get();
Here is the function declaration:
void mainLoop(vector<message> *msglist, vector<userLastSeen> *_reg_users, message* &buf, bool* &_msg_written);
But I get the following error:
In file included from /usr/include/c++/4.8/future:38:0,
from main.cpp:3:
/usr/include/c++/4.8/functional: In instantiation of ‘struct std::_Bind_simple<std::_Mem_fn<void (GUI::*)(std::vector<message>*, std::vector<userLastSeen>*, message*&, bool*&)>(GUI*, std::vector<message>*, std::vector<userLastSeen>*, message*, bool*)>’:
/usr/include/c++/4.8/future:1539:70: required from ‘std::future<typename std::result_of<_Functor(_ArgTypes ...)>::type> std::async(std::launch, _Fn&&, _Args&& ...) [with _Fn = void (GUI::*)(std::vector<message>*, std::vector<userLastSeen>*, message*&, bool*&); _Args = {GUI*&, std::vector<message, std::allocator<message> >*, std::vector<userLastSeen, std::allocator<userLastSeen> >*, message*&, bool*&}; typename std::result_of<_Functor(_ArgTypes ...)>::type = void]’
/usr/include/c++/4.8/future:1555:36: required from ‘std::future<typename std::result_of<_Functor(_ArgTypes ...)>::type> std::async(_Fn&&, _Args&& ...) [with _Fn = void (GUI::*)(std::vector<message>*, std::vector<userLastSeen>*, message*&, bool*&); _Args = {GUI*&, std::vector<message, std::allocator<message> >*, std::vector<userLastSeen, std::allocator<userLastSeen> >*, message*&, bool*&}; typename std::result_of<_Functor(_ArgTypes ...)>::type = void]’
main.cpp:68:74: required from here
/usr/include/c++/4.8/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (GUI::*)(std::vector<message>*, std::vector<userLastSeen>*, message*&, bool*&)>(GUI*, std::vector<message>*, std::vector<userLastSeen>*, message*, bool*)>’
typedef typename result_of<_Callable(_Args...)>::type result_type;
/usr/include/c++/4.8/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (GUI::*)(std::vector<message>*, std::vector<userLastSeen>*, message*&, bool*&)>(GUI*, std::vector<message>*, std::vector<userLastSeen>*, message*, bool*)>’
_M_invoke(_Index_tuple<_Indices...>)
^
make: *** [all] Error 1
Aucun commentaire:
Enregistrer un commentaire