boost::Unique_Ptr 对象列表
为什么我不能这样做?
typedef boost::interprocess::unique_ptr<QueueList, QueueListDeletor> UQList;
typedef boost::intrusive::list<UQList> List; // Compiler (VS 2003) complains
QueueList 是一个派生自 public boost::intrusive::list_base_hook
的类,使其成为侵入式链表的一部分。
我希望使用 unique_ptr 能够在线程之间传递该对象,并且当时只有 1 个线程拥有该对象的所有权。
编辑: 错误:
错误 C2039:“指针”:不是“boost::intrusive::detail::default_list_hook”的成员 请参阅“boost::intrusive::detail::default_list_hook”的声明 请参阅正在编译的类模板实例化“boost::intrusive::list_impl”的参考 和 [ Config=boost::intrusive::listopt::value_traits,boost::intrusive::size_type::pack>::type,boost::intrusive::constant_time_size>::type>::size_type,true> ]
错误 C2039:“const_pointer”:不是“boost::intrusive::detail::default_list_hook”的成员 请参阅“boost::intrusive::detail::default_list_hook”的声明
Why can I not do this?
typedef boost::interprocess::unique_ptr<QueueList, QueueListDeletor> UQList;
typedef boost::intrusive::list<UQList> List; // Compiler (VS 2003) complains
The QueueList is a class that derives from public boost::intrusive::list_base_hook<>
to make it part of an intrusive linked list.
I want to use unique_ptr to be able to pass around this object between threads and only have 1 single thread have ownership of this object at the time.
EDIT:
ERRORS:
error C2039: 'pointer' : is not a member of 'boost::intrusive::detail::default_list_hook'
see declaration of 'boost::intrusive::detail::default_list_hook'
see reference to class template instantiation 'boost::intrusive::list_impl' being compiled
with
[
Config=boost::intrusive::listopt::value_traits,boost::intrusive::size_type::pack>::type,boost::intrusive::constant_time_size>::type>::size_type,true>
]
error C2039: 'const_pointer' : is not a member of 'boost::intrusive::detail::default_list_hook'
see declaration of 'boost::intrusive::detail::default_list_hook'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
QueueList 可能源自 list_base_hook,但 UQList 肯定不是。由于您尝试创建 UQList(这是一个 unique_ptr)的侵入式列表而不是 QueueList 对象的侵入式列表,因此这是行不通的。
QueueList may be derived from list_base_hook, but UQList certainly isn't. Since you try to create an intrusive list of UQList (which is a unique_ptr) and not an intrusive list of QueueList objects, this won't work.