0
我想创建一个连接结构,其中有一个concurrent_queue和一个连接指针。由于我有一个未知数量的连接,这个结构将被推回到一个向量中。结构中的concurrent_queue
的载体和结构:
struct connection_struct {
concurrent_queue<string> messages_queue;
connection_ptr con;
connection_struct(concurrent_queue<string> queue) {
messages_queue = queue;
}
};
std::vector<connection_struct> allConnections;
这可以被编译,但是当我创建了结构,它不能再编译。我创建由结构:
boost::thread_group message_workers;
concurrent_queue<string> message_queue(&message_workers);
connection_struct viewer(message_queue);
编译错误是巨大的,但我认为这是相关的位:
In constructor ‘websocketpp::broadcast::handler<endpoint_type>::connection_struct::connection_struct(concurrent_queue<std::basic_string<char> >) [with endpoint_type = websocketpp::endpoint<websocketpp::role::server, websocketpp::socket::tls>]’:
broadcast_handler.hpp:284:21: note: synthesized method ‘concurrent_queue<std::basic_string<char> >& concurrent_queue<std::basic_string<char> >::operator=(concurrent_queue<std::basic_string<char> >&)’ first required here
任何线索我应该怎么办?谢谢!
我敢肯定,这将有助于如果你粘贴了整个错误信息并告诉我们'concurrent_queue'来自哪里。 – us2012 2013-03-20 15:50:06
看起来'concurrent_queue'不是可分配的,但根据http://msdn.microsoft.com/en-us/library/ee355375.aspx,是复制可构造的。所以:'connection_struct(concurrent_queue const&queue):messages_queue(queue){}' –
hmjd
2013-03-20 16:02:16