- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正尝试在我的代码中使用 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
有什么样的构造函数!你有默认构造函数吗??
关于c++ - boost::circular_buffer<unique_ptr<T>>::set_capacity() 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37757284/
我是cpp的新手。我想把“boost::circular_buffer histpos(5);”用 5 个空格将 5 个元素存储在 cpp 结构中作为成员。 我试试这个: typedef struct
我有 2 个进程:一个生产者和“消费者”,它们仍然在缓冲区中保留值,它们将被覆盖。 但是让消费者跟踪会带来一些问题。当缓冲区已满并且值被覆盖时,指向索引 0 的值是刚被覆盖的值之前的值(即下一个最旧的
我需要在处理到达进程 X 的对象之前对它们进行排序。 对象根据时间戳进行排序 - 一个 64 位数字。 当对象超时(几毫)并排序时,进程 X 开始查看它们。 大多数情况下,对象到达时是有序的,有 3%
我正在寻找一个允许在磁盘上获取循环缓冲区的库。 在 Boost 中有类似的东西,但它是一个基于内存的容器:circular_buffer . 最佳答案 你可以随意调用它。 您正在寻找内存映射文件。 使
以下编译失败: auto myCircularBuffer = boost::circular_buffer{1,2,3,4}; 有错误: `error: no matching function f
我在 MAC (xcode) 中使用 boost 库。我有两个关于 boost::circular_buffer 的问题。 1 - 声明 circular_buffer 时出现语法错误 boost::
是否强制存储std::shared_ptr在 boost::circular_buffer 中?如果我有 boost::circular_buffer循环队列delete是第n+1次插入后自动弹出的元
我正在使用 boost 1.73.0,并尝试将循环缓冲区与 manage_mapped_file 一起使用以将字符串存储在磁盘上持久的循环缓冲区中。 我执行以下操作来创建/打开循环缓冲区: boost
我面临以下情况(我不得不承认我太菜鸟了,不相信自己可以单独解决..):我有线程 A,它偶尔会创建新的 cv::Mat 对象供线程 B 使用。我需要一个线程安全的容器 C(在本例中为 boost::ci
阅读rationale , boost::circular_buffer 看起来很有希望: Suitability for real-time and performance critical app
我正在实现 boost::circular_buffer在boost::managed_shared_memory .我使用示例代码演示共享内存中的 vector here .我做了以下更改: 1)
我发现 Boost 实现了 KMP 算法,我想将它与 circular_buffer 一起使用,但我无法将其与组件相匹配。任何有 boost 经验的人都可以告诉我如何做到这一点。 最佳答案 您遇到了什
我想用 unique_ptrs 填充 boost::circular_buffer 但我在公共(public)接口(interface)中的任何函数中找不到任何“emplace”函数或任何 && 参数
我正尝试在我的代码中使用 boost::circular_buffer,如下所示: class EventRegistry { public: EventRegistry() {
我今天早些时候发现,boost::circular 缓冲区的迭代器在多线程环境中的表现并不像我预期的那样。 (尽管公平地说,它们的行为也与我在单线程程序中的想法不同)。 如果您调用 buffer.be
这段简单的代码将 2 个 bool 添加到循环缓冲区。 boost::circular_buffer stuff; stuff.push_back(false); stuff.push_back(tr
我使用 std::vector 编写了很多代码和 std::vector::iterator .现在我决定用 boost 的循环缓冲区替换 vector 容器,即 boost::circular_bu
我是一名优秀的程序员,十分优秀!