首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C++“错误:在‘class std::result_of< .>’中没有名为‘type’的类型

C++“错误:在‘class std::result_of< .>’中没有名为‘type’的类型
EN

Stack Overflow用户
提问于 2018-10-04 11:28:37
回答 1查看 1.2K关注 0票数 0

我正在尝试编译一个gRPC服务器,但是我得到了错误:

代码语言:javascript
运行
复制
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...>)

我猜是wavenet_server.cc中的这一行

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

引入歧义(编译器不知道这是函数解氯还是表达式?)

所以我试着用:

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

但这也行不通。

这是问题的正确根源吗?我该怎么解决呢?如果这行不是问题,那么请让我知道(源代码太长,无法粘贴,我无法分辨哪一行是问题,因为我无法理解错误消息,但我会尽力)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-04 12:20:10

如果要使用C++11功能(如std::result_of ),则需要更新GCC版本。GCC 4.8只有非常实验性的C++11支持。一般建议只在C++98模式下使用它。

如果您想在RedHatEnterpriseLinux7上使用C++11,您应该获得的最新版本:

对于CentOS,DTS可通过软件集合站点获得

请记住,由于DTS的工作方式,您需要使用DTS编译所有C++11代码,因此不能使用预编译的gRPC库。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52645571

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档