Closed baylf2000 closed 2 years ago
The limitation is because this line cannot throw: https://github.com/rigtorp/MPMCQueue/blob/master/include/rigtorp/MPMCQueue.h#L185. std::string
copy constructor can throw if allocation fails.
If you move MyEvent
into the queue using try_emplace(std::move(myEvent))
it should work.
I'm running into a compile issue using a struct containing a std::string as the type when constructing a new MPMCQueue.
For example, using a struct:
and trying to construct a MPMCQueue:
MPMCQueue<MyEvent> EventQueue(100);
I get a compiler message:
"T must be nothrow copy constructible".
If I remove the std::string from the struct and replace it with another long for example, it compiles and works perfectly. It also works perfectly if I use just a std::string in constructing the queue. But not when it's used inside the struct.
Any advice would be appreciated.