简体   繁体   English

boost :: Unique_Ptr对象列表

[英]List of boost::Unique_Ptr objects

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. QueueList是一个类,它从public boost::intrusive::list_base_hook<>派生而来,使其成为侵入式链接列表的一部分。

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. 我想使用unique_ptr能够在线程之间传递该对象,并且当时只有1个单线程对此对象拥有所有权。

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> ] 错误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>]

error C2039: 'const_pointer' : is not a member of 'boost::intrusive::detail::default_list_hook' see declaration of 'boost::intrusive::detail::default_list_hook' 错误C2039:'const_pointer':不是'boost :: intrusive :: detail :: default_list_hook'的成员,请参见'boost :: intrusive :: detail :: default_list_hook'的声明

QueueList may be derived from list_base_hook, but UQList certainly isn't. QueueList可以从list_base_hook派生,但是UQList当然不是。 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. 由于您尝试创建UQList的侵入式列表(这是unique_ptr)而不是QueueList对象的侵入式列表,因此将无法使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM