0
我想通过引用传递给线程,一个变量定义为:不能按引用传递到线程
zmq::context_t context(1);
这样的:
t[thread_nbr] = std::thread(worker_routine, (void *)&context, trained_images);
然而,当我做我得到的以下错误:
/usr/include/c++/5/functional:1505:61: error: no type named ‘type’ in ‘class std::result_of<void* (*(void*, std::vector<TrainedImage>))(void*, std::vector<TrainedImage>&)>’
typedef typename result_of<_Callable(_Args...)>::type result_type;
^
/usr/include/c++/5/functional:1526:9: error: no type named ‘type’ in ‘class std::result_of<void* (*(void*, std::vector<TrainedImage>))(void*, std::vector<TrainedImage>&)>’
_M_invoke(_Index_tuple<_Indices...>)
如果我尝试做std::ref()
有了它,我收到了删除功能的错误。
有谁知道我能做什么?
是什么'worker_routine'的签名? – user463035818
[Off Topic]当你使用'std :: thread'时,你真的不需要将任何东西投射到'void *'。它被设计用于类型系统。 – NathanOliver
您可以尝试创建一个[最小,完整和可验证示例](http://stackoverflow.com/help/mcve)并向我们展示?包括'worker_routine'和'trained_images'的声明(至少)。 –