C++ 如何使用spsc_queue.pop()这个结构?
我正在尝试C++ 如何使用spsc_queue.pop()这个结构?,c++,boost,struct,queue,lock-free,C++,Boost,Struct,Queue,Lock Free,我正在尝试spsc\u queue.pop()thisstruct enum action_type { SUBSCRIBE, UNSUBSCRIBE, MESSAGE }; struct action { action() = default ; action(action_type t, connection_hdl h) : type(t), hdl(h) {} action(action_type t, server::message_p
spsc\u queue.pop()
thisstruct
enum action_type {
SUBSCRIBE,
UNSUBSCRIBE,
MESSAGE
};
struct action {
action() = default ;
action(action_type t, connection_hdl h) : type(t), hdl(h) {}
action(action_type t, server::message_ptr m) : type(t), msg(m) {}
action_type type;
websocketpp::connection_hdl hdl;
server::message_ptr msg;
};
与
但是每当我用
std::cout << "'" << a.type << "'" << std::endl;
std::coutSUBSCRIBE
的值为0
。如果要给SUBSCRIBE
一个不同的值,可以初始化枚举数,例如,使用1
:
enum action_type {
SUBSCRIBE = 1,
UNSUBSCRIBE,
MESSAGE
};
其他枚举数将获得相应的下一个整数值
enum action_type {
SUBSCRIBE = 1,
UNSUBSCRIBE,
MESSAGE
};