MyClass
我在另一个类中有一个结构,MyOuterClass
我试图将其放入 boost::lockfree::queue 中。我的结构如下所示
struct MyClass
{
MyClass() {}
MyClass(const string& topic, const string& multicastChannel, const string& netInterface, MyOuterClass::MY_COMMAND_ENUM command, MyOuterClass::CallbackType callback)
:topic(topic), multicastChannel(multicastChannel), netInterface(netInterface), command(command), callback(callback) {}
MyClass(const MyClass& src)
:topic(src.topic), multicastChannel(src.multicastChannel), netInterface(src.netInterface), command(src.command), callback(src.callback) {}
MyClass& operator=(const MyClass& src)
{
topic = src.topic;
multicastChannel = src.multicastChannel;
netInterface = src.netInterface;
command = src.command;
callback = src.callback;
}
~MyClass(){}
string topic;
string multicastChannel;
string netInterface;
MyOuterClass::MY_COMMAND_ENUM command;
MyOuterClass::CallbackType callback;
};
我的外部类有一个公共成员变量boost::lockfree::queue<MyClass> m_commandQueue;
,当我尝试编译时会引发以下错误。
1>------ Build started: Project: MDServices, Configuration: Debug x64 ------
1>Build started 6/10/2013 4:41:00 PM.
1>InitializeBuildStatus:
1> Touching "x64\Debug\MDServices.unsuccessfulbuild".
1>ClCompile:
1> MyOuterClass.cpp
1>C:\local\boost_1_53_0\boost/lockfree/queue.hpp(79): error C2338: (boost::has_trivial_destructor<T>::value)
1> src\MyOuterClass.cpp(70) : see reference to class template instantiation 'boost::lockfree::queue<T>' being compiled
1> with
1> [
1> T=MDServices::MyClass
1> ]
1>C:\local\boost_1_53_0\boost/lockfree/queue.hpp(83): error C2338: (boost::has_trivial_assign<T>::value)
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.38
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我检查了线程/boost/lockfree/queue.hpp: error: static assertion failed: (boost::has_trivial_destructor<T>::value)但是我仍然无法编译。我在这里想念什么?
谢谢。
钦梅