jeudi 4 octobre 2018

C++ "error: no type named ‘type’ in ‘class std::result_of< ... >"

I am trying to compile a gRPC server, but I get the error:

In file included from /usr/include/c++/4.8.2/mutex:42:0,
                 from /usr/include/c++/4.8.2/condition_variable:39,
                 from /home/msl/maum/include/grpc++/server.h:22,
                 from wavenet_server.cc:2:
/usr/include/c++/4.8.2/functional: In instantiation of ‘struct std::_Bind_simple<std::_Mem_fn<void* (WavenetServiceImpl::*)(void*)>(void**)>’:
/usr/include/c++/4.8.2/thread:137:47:   required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void* (WavenetServiceImpl::*)(void*); _Args = {void* (&)[2]}]’
wavenet_server.cc:317:73:   required from here
/usr/include/c++/4.8.2/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void* (WavenetServiceImpl::*)(void*)>(void**)>’
       typedef typename result_of<_Callable(_Args...)>::type result_type;
                                                             ^
/usr/include/c++/4.8.2/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void* (WavenetServiceImpl::*)(void*)>(void**)>’
         _M_invoke(_Index_tuple<_Indices...>)

My guess is this line in wavenet_server.cc:

std::thread t(&WavenetServiceImpl::threadWavenetInfer, thread_args);

is introducing ambiguity ( the compiler does not know if this is a function decloration or an expression, maybe? )

So I tried to replace the line with:

std::thread t{&WavenetServiceImpl::threadWavenetInfer, thread_args};

but that did not work either

Is this the correct source of the problem? and how may I fix it? If that line is not the problem, then please let me know ( The source code is too long to paste, and I cannot tell which line is the problem because I cannot understand the error message, but I will try my best ).

Aucun commentaire:

Enregistrer un commentaire