boost::circular_buffer<unique_ptr<T>>::set_capacity() 无法构建
boost::circular_buffer<unique_ptr<T>>::set_capacity() fails to build
我正在尝试在我的代码中使用boost::circular_buffer
,如下所示:
class EventRegistry
{
public:
EventRegistry()
{
pendingEvents_.set_capacity(MAX_PENDING_EVENTS);
}
private:
boost::circular_buffer<boost::movelib::unique_ptr<EventData>> pendingEvents_;
}
但是,我遇到了构建失败(摘录):
...
boost/build/binaries/include/boost/circular_buffer/details.hpp:470:12: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept_impl<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
return uninitialized_move_if_noexcept_impl(first, last, dest, a, tag_t());
^
boost/build/binaries/include/boost/circular_buffer/base.hpp:955:37: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
reset(buff, cb_details::uninitialized_move_if_noexcept(e - (std::min)(new_capacity, size()),
^
events/event_registry.cc:22:18: note: in instantiation of member function 'boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::rset_capacity' requested here
pendingEvents_.rset_capacity(MAX_PENDING_EVENTS);
...
但是,如果我在构造函数中使用初始值设定项:
EventRegistry()
: pendingEvents_(MAX_PENDING_EVENTS)
然后它编译得很好。有什么线索吗?
更新:这是完整的输出(对不起长度)
boost/build/binaries/include/boost/container/allocator_traits.hpp:408:51: error: no matching constructor for initialization of 'boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >'
{ ::new((void*)p, boost_container_new_t()) T(::boost::forward<Args>(args)...); }
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boost/build/binaries/include/boost/container/allocator_traits.hpp:353:28: note: in instantiation of function template specialization 'boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::priv_construct<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > >' requested here
allocator_traits::priv_construct(flag, a, p, ::boost::forward<Args>(args)...);
^
boost/build/binaries/include/boost/circular_buffer/details.hpp:439:56: note: in instantiation of function template specialization 'boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::construct<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > >' requested here
boost::container::allocator_traits<Alloc>::construct(a, boost::addressof(*dest), *first);
^
boost/build/binaries/include/boost/circular_buffer/details.hpp:460:12: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_copy<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
return uninitialized_copy(first, last, dest, a);
^
boost/build/binaries/include/boost/circular_buffer/details.hpp:470:12: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept_impl<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
return uninitialized_move_if_noexcept_impl(first, last, dest, a, tag_t());
^
boost/build/binaries/include/boost/circular_buffer/base.hpp:880:29: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
cb_details::uninitialized_move_if_noexcept(b, b + (std::min)(new_capacity, size()), buff, m_alloc),
^
.../events/event_registry.cc:22:18: note: in instantiation of member function 'boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::set_capacity' requested here
pendingEvents_.set_capacity(MAX_EVENTS_PER_TIMEWINDOW);
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:360:35: note: candidate constructor not viable: 1st argument ('const boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >') would lose const qualifier
BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_ptr)
^
boost/build/binaries/include/boost/move/core.hpp:242:46: note: expanded from macro 'BOOST_MOVABLE_BUT_NOT_COPYABLE'
BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE)
^
boost/build/binaries/include/boost/move/core.hpp:35:7: note: expanded from macro 'BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN'
TYPE(TYPE &);
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:401:20: note: candidate constructor not viable: no known conversion from 'const boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >' to 'bmupd::nullptr_type' (aka 'int (boost::move_upd::bool_conversion::*)()') for 1st argument
BOOST_CONSTEXPR unique_ptr(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type)) BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:527:4: note: candidate constructor not viable: no known conversion from 'const boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >' to '::boost::rv<unique_ptr<EventData, default_delete<EventData> > > &' for 1st argument
unique_ptr(BOOST_RV_REF(unique_ptr) u) BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:424:13: note: candidate template ignored: substitution failure [with Pointer = boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >]: no type named 'type' in 'boost::move_upd::enable_up_ptr<appd::agent::EventData, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, appd::agent::EventData *, boost::move_upmu::nat>'
explicit unique_ptr(Pointer p
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:462:4: note: candidate constructor template not viable: requires at least 2 arguments, but 1 was provided
unique_ptr(Pointer p, BOOST_MOVE_SEEDOC(deleter_arg_type1) d1
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:500:4: note: candidate constructor template not viable: requires at least 2 arguments, but 1 was provided
unique_ptr(Pointer p, BOOST_MOVE_SEEDOC(deleter_arg_type2) d2
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:547:4: note: candidate template ignored: instantiation would take its own class type by value
unique_ptr( BOOST_RV_REF_BEG_IF_CXX11 unique_ptr<U, E> BOOST_RV_REF_END_IF_CXX11 u
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:390:20: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
BOOST_CONSTEXPR unique_ptr() BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:475:4: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
unique_ptr(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type), BOOST_MOVE_SEEDOC(deleter_arg_type1) d1) BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:513:4: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
unique_ptr(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type), BOOST_MOVE_SEEDOC(deleter_arg_type2) d2) BOOST_NOEXCEPT
^
1 error generated.
下面的编译就好了...
#include <boost/circular_buffer.hpp>
#include <boost/move/unique_ptr.hpp>
class EventRegistry
{
public:
EventRegistry()
{
pendingEvents_.set_capacity(10);
}
private:
boost::circular_buffer<boost::movelib::unique_ptr<int>> pendingEvents_;
};
int main()
{
return 0;
}
请注意,我在您EventData
的位置放置了一个int
。你的问题可能与EventData
有关。
(我没有足够的观点,发表评论...
编辑:哦,检查一下EventData
有什么样的构造函数!你有默认构造函数吗?
相关文章:
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 呼叫运营商<<临时
- 如何防止clang格式在流运算符调用之间添加换行符<<
- <<操作员在下面的行中工作
- EASTL矢量<向量<int>>连续的
- C - 创建矢量&lt; vector&lt; double&gt;&gt;矩阵具有分配而不是inizializ
- 为什么将此对向量&lt; map&lt; int,int&gt;&gt;中的地图进行更新.失败
- C :对矢量进行排序&lt; struct&gt;(结构有2个整数)基于结构的整数之一
- 明确的专业化“ CheckIntmap&lt;&gt;”实例化
- 什么是模板&lt;&gt;inline bla bla
- 编辑C Qlist&lt; object*&gt; gt;QML代码和一些QML警告中的模型
- eigen :: llt&lt;eigen :: matrixxd&gt;具有不完整的类型
- 错误,包括&lt; ctype&gt;在原子上使用C 11
- std::vector<;uint8_t>;当C++11/14启用时,手动复制而不是调用memcpy
- 如何加入向量&lt; int&gt;到C 中的单个INT
- 是std :: set&lt; std :: future&gt;不可能存在
- 是numeric_limits&lt; int&gt; :: is_modulo从逻辑上矛盾
- opencv 2.4.7在iOS错误背景_segm.hpp #include&lt; list&gt;未找到
- 在修改列表后,std :: list&lt; t&gt; :: end()的值是否会更改
- ///<评论></评论>在Visual Studio中