{错误 C2338: (boost::has_trivial_destructor:<T>:value)} 对于 boost::lockfree::queue 是什么意思?我在这里错过了什
What does {error C2338: (boost::has_trivial_destructor<T>::value)} mean for boost::lockfree::queue ? What am I missing here?
我在另一个类MyOuterClass
中有一个结构体MyClass
,我试图放入boost::lockfree::队列。我的结构如下
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 "x64DebugMDServices.unsuccessfulbuild".
1>ClCompile:
1> MyOuterClass.cpp
1>C:localboost_1_53_0boost/lockfree/queue.hpp(79): error C2338: (boost::has_trivial_destructor<T>::value)
1> srcMyOuterClass.cpp(70) : see reference to class template instantiation 'boost::lockfree::queue<T>' being compiled
1> with
1> [
1> T=MDServices::MyClass
1> ]
1>C:localboost_1_53_0boost/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:错误:静态断言失败:(boost::has_trivial_destructor
谢谢。
Chinmay
根据JesseGood对我的问题的评论,这个问题是由于在MyClass
中使用std::string
引起的,这是不平凡的。解决方案是将指向MyClass
的指针直接存储在我的boost::lockfree::queue
而不是MyClass
对象中。
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- boost::进程间消息队列引发错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- cmake如何在fedora工作站中找到boost静态库包
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- Boost Graph Library,修复节点大小
- 什么是"#include <boost/functional/hash.hpp> "?
- 基于boost的程序的静态链接——zlib问题
- C++:如何在CLion IDE中安装Boost
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 如何在boost beast http请求中设置http头
- Boost Spirit,获取迭代器内部语义动作
- 是boost :: lockfree :: Queue(在多线程程序中)可锁定
- 在 boost::lockfree:queue 默认构造函数的情况下断言失败
- boost::lockfree::queue允许的数据结构示例
- 如何将std::string放入boost::lockfree::queue(或备选方案)
- {错误 C2338: (boost::has_trivial_destructor:<T>:value)} 对于 boost::lockfree::queue 是什么意思?我在这里错过了什
- /boost/lockfree/queue.hpp:错误:静态断言失败:(boost::has_trivial_destructor<T>::value)
- 在c++11中,boost::lockfree::queue不是lockfree的
- 共享内存中的boost::lockfree::queue出现问题(boost1.53,gcc4.7.2/clang3.0